Skip to content

Commit b5986d2

Browse files
committed
Initial commit
0 parents  commit b5986d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+2697
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.settings
2+
/.project
3+
/.buildpath
4+
/vendor
5+
.idea
6+
nbproject

.travis.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
language: php
2+
3+
php:
4+
- 5.4
5+
6+
before_script:
7+
- composer self-update
8+
- composer update
9+
10+
script:
11+
- php ./vendor/bin/phpunit -c ./tests/.

LICENSE.txt

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2014, Alexander Miertsch kontakt@codeliner.ws
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
* Redistributions of source code must retain the above copyright notice,
8+
this list of conditions and the following disclaimer.
9+
10+
* Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
* Neither the name of Alexander Miertsch nor the names of its
15+
contributors may be used to endorse or promote products derived from this
16+
software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
ProophEventStore
2+
===================
3+
PHP 5.4+ EventSourcing library.
4+
5+
##Features
6+
- Event driven library [in progress]
7+
- Full DDD support [in progress]
8+
- Collection based repositories [done]
9+
- Support for ValueObjects as AggregateRoot identifiers [done]
10+
- Transaction handling [done]
11+
- Optional snapshot strategies [not started]
12+
- Optional concurrent logging [not started]
13+
- Link your own event dispatcher and/or connect ProophServiceBus [not started]
14+
- Changeable storage adapter like
15+
-- ZF2 Tablegateway [in progress]
16+
-- doctrine dbal [not started]
17+
-- mongoDB [not started]
18+
-- geteventstore client [not started]
19+
20+
##ZF2 insight
21+
The ProophEventStore is based on ZF2 components which offer a lot of customization options.
22+
23+
##Quick start
24+
coming soon ...
25+
26+
##Contribution
27+
coming soon ...
28+
29+
##Wiki
30+
coming soon ...
31+
32+
33+
34+

composer.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"name": "prooph/event-store",
3+
"description": "PHP EventStore library",
4+
"type": "library",
5+
"license": "BSD-3-Clause",
6+
"homepage": "https://github.com/prooph/event-store/",
7+
"authors": [
8+
{
9+
"name": "Alexander Miertsch",
10+
"email": "contact@prooph.de",
11+
"homepage": "http://www.prooph.de/"
12+
}
13+
],
14+
"keywords": [
15+
"php",
16+
"EventSourcing",
17+
"EventStore",
18+
"library",
19+
"DDD",
20+
"prooph",
21+
"zf2"
22+
],
23+
"require": {
24+
"php": ">=5.4",
25+
"rhumsaa/uuid" : "2.5.*",
26+
"codeliner/php-equalsbuilder": "1.1.*",
27+
"codeliner/array-reader": "1.0.*",
28+
"codeliner/shared-domain-set": "1.2.*",
29+
"beberlei/assert": "*",
30+
"zendframework/zend-servicemanager" : "2.3.*",
31+
"zendframework/zend-eventmanager" : "2.3.*",
32+
"zendframework/zend-db" : "2.3.*",
33+
"zendframework/zend-serializer" : "2.3.*"
34+
},
35+
"suggest": {
36+
"doctrine/dbal": "Use Doctrine\\DBAL as EventStore-Adapter"
37+
},
38+
"require-dev": {
39+
"phpunit/phpunit": "3.7.*"
40+
},
41+
"autoload": {
42+
"psr-0": {
43+
"Prooph\\EventStore\\": "src/",
44+
"Prooph\\EventStoreTest\\": "tests/"
45+
}
46+
}
47+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store package.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*/
9+
namespace Prooph\EventStore\Adapter;
10+
11+
use Prooph\EventStore\EventSourcing\AggregateChangedEvent;
12+
13+
/**
14+
* Interface of an EventStore Adapter
15+
*
16+
* @author Alexander Miertsch <contact@prooph.de>
17+
* @package Prooph\EventStore\Adapter
18+
*/
19+
interface AdapterInterface
20+
{
21+
/**
22+
* Load EventStream of an EventSourcedAggregateRoot from given version on
23+
*
24+
* Pass null as version to get the complete stream
25+
*
26+
* @param string $aggregateFQCN
27+
* @param string $aggregateId
28+
* @param int $version
29+
*
30+
* @return AggregateChangedEvent[]
31+
*/
32+
public function loadStream($aggregateFQCN, $aggregateId, $version = null);
33+
34+
/**
35+
* Add events to the source stream
36+
*
37+
* @param string $aggregateFQCN
38+
* @param string $aggregateId
39+
* @param AggregateChangedEvent[] $events
40+
*
41+
* @return void
42+
*/
43+
public function addToStream($aggregateFQCN, $aggregateId, $events);
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Date: 17.04.14 - 22:41
10+
*/
11+
12+
namespace Prooph\EventStore\Adapter\Builder;
13+
14+
/**
15+
* Class AggregateIdBuilder
16+
*
17+
* @package Prooph\EventStore\Adapter\Builder
18+
* @author Alexander Miertsch <contact@prooph.de>
19+
*/
20+
class AggregateIdBuilder
21+
{
22+
protected static $typeMap = array();
23+
24+
/**
25+
* @param string $aggregateIdFQCN
26+
* @param string $typeFQCN
27+
*/
28+
public static function registerType($aggregateIdFQCN, $typeFQCN)
29+
{
30+
static::$typeMap[$aggregateIdFQCN] = $typeFQCN;
31+
}
32+
33+
/**
34+
* @param mixed $aggregateId
35+
* @return string
36+
*/
37+
public static function toString($aggregateId)
38+
{
39+
if (is_string($aggregateId)) {
40+
return $aggregateId;
41+
}
42+
43+
if (is_object($aggregateId)) {
44+
if (isset(static::$typeMap[get_class($aggregateId)])) {
45+
$typeClass = static::$typeMap[get_class($aggregateId)];
46+
$type = new $typeClass();
47+
48+
return $type->convertToString($aggregateId);
49+
}
50+
}
51+
52+
return (string)$aggregateId;
53+
}
54+
}
55+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Date: 17.04.14 - 22:44
10+
*/
11+
12+
namespace Prooph\EventStore\Adapter\Builder;
13+
14+
/**
15+
* Interface AggregateIdType
16+
*
17+
* @package Prooph\EventStore\Adapter\Builder
18+
* @author Alexander Miertsch <contact@prooph.de>
19+
*/
20+
interface AggregateIdType
21+
{
22+
/**
23+
* @param mixed $aggregateId
24+
* @return string
25+
*/
26+
public function convertToString($aggregateId);
27+
}
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Date: 17.04.14 - 20:56
10+
*/
11+
12+
namespace Prooph\EventStore\Adapter\Builder;
13+
14+
use Prooph\EventStore\EventSourcing\AggregateChangedEvent;
15+
use Rhumsaa\Uuid\Uuid;
16+
use ValueObjects\DateTime\DateTime;
17+
18+
/**
19+
* Class EventBuilder
20+
*
21+
* @package Prooph\EventStore\Adapter\Builder
22+
* @author Alexander Miertsch <contact@prooph.de>
23+
*/
24+
class EventBuilder
25+
{
26+
/**
27+
* @param string $eventFQCN
28+
* @param Uuid $uuid
29+
* @param mixed $aggregateId
30+
* @param DateTime $occurredOn
31+
* @param int $version
32+
* @param array $payload
33+
* @return AggregateChangedEvent
34+
*/
35+
public static function reconstructEvent($eventFQCN, Uuid $uuid, $aggregateId, DateTime $occurredOn, $version, array $payload)
36+
{
37+
$eventRef = new \ReflectionClass($eventFQCN);
38+
39+
$event = $eventRef->newInstanceWithoutConstructor();
40+
41+
$uuidProp = $eventRef->getProperty('uuid');
42+
43+
$uuidProp->setAccessible(true);
44+
45+
$uuidProp->setValue($event, $uuid);
46+
47+
$aggregateIdProp = $eventRef->getProperty('aggregateId');
48+
49+
$aggregateIdProp->setAccessible(true);
50+
51+
$aggregateIdProp->setValue($event, $aggregateId);
52+
53+
$occurredOnProp = $eventRef->getProperty('occurredOn');
54+
55+
$occurredOnProp->setAccessible(true);
56+
57+
$occurredOnProp->setValue($event, $occurredOn);
58+
59+
$versionProp = $eventRef->getProperty('version');
60+
61+
$versionProp->setAccessible(true);
62+
63+
$versionProp->setValue($event, $version);
64+
65+
$payloadProp = $eventRef->getProperty('payload');
66+
67+
$payloadProp->setAccessible(true);
68+
69+
$payloadProp->setValue($event, $payload);
70+
71+
return $event;
72+
}
73+
}
74+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Date: 17.04.14 - 20:40
10+
*/
11+
12+
namespace Prooph\EventStore\Adapter\Exception;
13+
use Prooph\EventStore\Exception\EventStoreException;
14+
15+
/**
16+
* Marker interface AdapterException
17+
*
18+
* @package Prooph\EventStore\Adapter\Exception
19+
* @author Alexander Miertsch <contact@prooph.de>
20+
*/
21+
interface AdapterException extends EventStoreException
22+
{
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/*
3+
* This file is part of the prooph/event-store.
4+
* (c) Alexander Miertsch <contact@prooph.de>
5+
*
6+
* For the full copyright and license information, please view the LICENSE
7+
* file that was distributed with this source code.
8+
*
9+
* Date: 17.04.14 - 20:41
10+
*/
11+
12+
namespace Prooph\EventStore\Adapter\Exception;
13+
14+
/**
15+
* Class ConfigurationException
16+
*
17+
* @package Prooph\EventStore\Adapter\Exception
18+
* @author Alexander Miertsch <contact@prooph.de>
19+
*/
20+
class ConfigurationException extends \RuntimeException implements AdapterException
21+
{
22+
}
23+

0 commit comments

Comments
 (0)