Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
42 changed files
with
2,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/.settings | ||
/.project | ||
/.buildpath | ||
/vendor | ||
.idea | ||
nbproject |
11
.travis.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
language: php | ||
|
||
php: | ||
- 5.4 | ||
|
||
before_script: | ||
- composer self-update | ||
- composer update | ||
|
||
script: | ||
- php ./vendor/bin/phpunit -c ./tests/. |
27
LICENSE.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Copyright (c) 2014, Alexander Miertsch kontakt@codeliner.ws | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of Alexander Miertsch nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
34
README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
ProophEventStore | ||
=================== | ||
PHP 5.4+ EventSourcing library. | ||
|
||
##Features | ||
- Event driven library [in progress] | ||
- Full DDD support [in progress] | ||
- Collection based repositories [done] | ||
- Support for ValueObjects as AggregateRoot identifiers [done] | ||
- Transaction handling [done] | ||
- Optional snapshot strategies [not started] | ||
- Optional concurrent logging [not started] | ||
- Link your own event dispatcher and/or connect ProophServiceBus [not started] | ||
- Changeable storage adapter like | ||
-- ZF2 Tablegateway [in progress] | ||
-- doctrine dbal [not started] | ||
-- mongoDB [not started] | ||
-- geteventstore client [not started] | ||
|
||
##ZF2 insight | ||
The ProophEventStore is based on ZF2 components which offer a lot of customization options. | ||
|
||
##Quick start | ||
coming soon ... | ||
|
||
##Contribution | ||
coming soon ... | ||
|
||
##Wiki | ||
coming soon ... | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"name": "prooph/event-store", | ||
"description": "PHP EventStore library", | ||
"type": "library", | ||
"license": "BSD-3-Clause", | ||
"homepage": "https://github.com/prooph/event-store/", | ||
"authors": [ | ||
{ | ||
"name": "Alexander Miertsch", | ||
"email": "contact@prooph.de", | ||
"homepage": "http://www.prooph.de/" | ||
} | ||
], | ||
"keywords": [ | ||
"php", | ||
"EventSourcing", | ||
"EventStore", | ||
"library", | ||
"DDD", | ||
"prooph", | ||
"zf2" | ||
], | ||
"require": { | ||
"php": ">=5.4", | ||
"rhumsaa/uuid" : "2.5.*", | ||
"codeliner/php-equalsbuilder": "1.1.*", | ||
"codeliner/array-reader": "1.0.*", | ||
"codeliner/shared-domain-set": "1.2.*", | ||
"beberlei/assert": "*", | ||
"zendframework/zend-servicemanager" : "2.3.*", | ||
"zendframework/zend-eventmanager" : "2.3.*", | ||
"zendframework/zend-db" : "2.3.*", | ||
"zendframework/zend-serializer" : "2.3.*" | ||
}, | ||
"suggest": { | ||
"doctrine/dbal": "Use Doctrine\\DBAL as EventStore-Adapter" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "3.7.*" | ||
}, | ||
"autoload": { | ||
"psr-0": { | ||
"Prooph\\EventStore\\": "src/", | ||
"Prooph\\EventStoreTest\\": "tests/" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store package. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Prooph\EventStore\Adapter; | ||
|
||
use Prooph\EventStore\EventSourcing\AggregateChangedEvent; | ||
|
||
/** | ||
* Interface of an EventStore Adapter | ||
* | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
* @package Prooph\EventStore\Adapter | ||
*/ | ||
interface AdapterInterface | ||
{ | ||
/** | ||
* Load EventStream of an EventSourcedAggregateRoot from given version on | ||
* | ||
* Pass null as version to get the complete stream | ||
* | ||
* @param string $aggregateFQCN | ||
* @param string $aggregateId | ||
* @param int $version | ||
* | ||
* @return AggregateChangedEvent[] | ||
*/ | ||
public function loadStream($aggregateFQCN, $aggregateId, $version = null); | ||
|
||
/** | ||
* Add events to the source stream | ||
* | ||
* @param string $aggregateFQCN | ||
* @param string $aggregateId | ||
* @param AggregateChangedEvent[] $events | ||
* | ||
* @return void | ||
*/ | ||
public function addToStream($aggregateFQCN, $aggregateId, $events); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 17.04.14 - 22:41 | ||
*/ | ||
|
||
namespace Prooph\EventStore\Adapter\Builder; | ||
|
||
/** | ||
* Class AggregateIdBuilder | ||
* | ||
* @package Prooph\EventStore\Adapter\Builder | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
*/ | ||
class AggregateIdBuilder | ||
{ | ||
protected static $typeMap = array(); | ||
|
||
/** | ||
* @param string $aggregateIdFQCN | ||
* @param string $typeFQCN | ||
*/ | ||
public static function registerType($aggregateIdFQCN, $typeFQCN) | ||
{ | ||
static::$typeMap[$aggregateIdFQCN] = $typeFQCN; | ||
} | ||
|
||
/** | ||
* @param mixed $aggregateId | ||
* @return string | ||
*/ | ||
public static function toString($aggregateId) | ||
{ | ||
if (is_string($aggregateId)) { | ||
return $aggregateId; | ||
} | ||
|
||
if (is_object($aggregateId)) { | ||
if (isset(static::$typeMap[get_class($aggregateId)])) { | ||
$typeClass = static::$typeMap[get_class($aggregateId)]; | ||
$type = new $typeClass(); | ||
|
||
return $type->convertToString($aggregateId); | ||
} | ||
} | ||
|
||
return (string)$aggregateId; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 17.04.14 - 22:44 | ||
*/ | ||
|
||
namespace Prooph\EventStore\Adapter\Builder; | ||
|
||
/** | ||
* Interface AggregateIdType | ||
* | ||
* @package Prooph\EventStore\Adapter\Builder | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
*/ | ||
interface AggregateIdType | ||
{ | ||
/** | ||
* @param mixed $aggregateId | ||
* @return string | ||
*/ | ||
public function convertToString($aggregateId); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 17.04.14 - 20:56 | ||
*/ | ||
|
||
namespace Prooph\EventStore\Adapter\Builder; | ||
|
||
use Prooph\EventStore\EventSourcing\AggregateChangedEvent; | ||
use Rhumsaa\Uuid\Uuid; | ||
use ValueObjects\DateTime\DateTime; | ||
|
||
/** | ||
* Class EventBuilder | ||
* | ||
* @package Prooph\EventStore\Adapter\Builder | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
*/ | ||
class EventBuilder | ||
{ | ||
/** | ||
* @param string $eventFQCN | ||
* @param Uuid $uuid | ||
* @param mixed $aggregateId | ||
* @param DateTime $occurredOn | ||
* @param int $version | ||
* @param array $payload | ||
* @return AggregateChangedEvent | ||
*/ | ||
public static function reconstructEvent($eventFQCN, Uuid $uuid, $aggregateId, DateTime $occurredOn, $version, array $payload) | ||
{ | ||
$eventRef = new \ReflectionClass($eventFQCN); | ||
|
||
$event = $eventRef->newInstanceWithoutConstructor(); | ||
|
||
$uuidProp = $eventRef->getProperty('uuid'); | ||
|
||
$uuidProp->setAccessible(true); | ||
|
||
$uuidProp->setValue($event, $uuid); | ||
|
||
$aggregateIdProp = $eventRef->getProperty('aggregateId'); | ||
|
||
$aggregateIdProp->setAccessible(true); | ||
|
||
$aggregateIdProp->setValue($event, $aggregateId); | ||
|
||
$occurredOnProp = $eventRef->getProperty('occurredOn'); | ||
|
||
$occurredOnProp->setAccessible(true); | ||
|
||
$occurredOnProp->setValue($event, $occurredOn); | ||
|
||
$versionProp = $eventRef->getProperty('version'); | ||
|
||
$versionProp->setAccessible(true); | ||
|
||
$versionProp->setValue($event, $version); | ||
|
||
$payloadProp = $eventRef->getProperty('payload'); | ||
|
||
$payloadProp->setAccessible(true); | ||
|
||
$payloadProp->setValue($event, $payload); | ||
|
||
return $event; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 17.04.14 - 20:40 | ||
*/ | ||
|
||
namespace Prooph\EventStore\Adapter\Exception; | ||
use Prooph\EventStore\Exception\EventStoreException; | ||
|
||
/** | ||
* Marker interface AdapterException | ||
* | ||
* @package Prooph\EventStore\Adapter\Exception | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
*/ | ||
interface AdapterException extends EventStoreException | ||
{ | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/event-store. | ||
* (c) Alexander Miertsch <contact@prooph.de> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 17.04.14 - 20:41 | ||
*/ | ||
|
||
namespace Prooph\EventStore\Adapter\Exception; | ||
|
||
/** | ||
* Class ConfigurationException | ||
* | ||
* @package Prooph\EventStore\Adapter\Exception | ||
* @author Alexander Miertsch <contact@prooph.de> | ||
*/ | ||
class ConfigurationException extends \RuntimeException implements AdapterException | ||
{ | ||
} | ||
|
Oops, something went wrong.