• Stars
    star
    100
  • Rank 333,455 (Top 7 %)
  • Language
    PHP
  • License
    BSD 3-Clause "New...
  • Created over 8 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Laravel package for prooph components to get started out of the box with message bus, CQRS, event sourcing and snapshots

Laravel package for prooph components

Overview

This is a Laravel package for prooph components to get started out of the box with message bus, CQRS, event sourcing and snapshots. It uses the prooph/pdo-event-store event store however there are more adapters available.

It provides all service definitions and a default configuration. This is more like a Quick-Start package. If you want to use the prooph components in production, we recommend to configure the prooph components for your requirements. See the documentation for more details of the prooph components.

For rapid prototyping we recommend to use our prooph-cli tool.

Available services

  • Prooph\ServiceBus\CommandBus: Dispatches commands
  • Prooph\ServiceBus\EventBus: Dispatches events
  • Prooph\ServiceBus\QueryBus: Allows for querying over a message bus.
  • Prooph\EventStoreBusBridge\TransactionManager: Transaction manager for service bus and event store
  • Prooph\EventStoreBusBridge\EventPublisher: Publishes events on the event bus

Available event stores

  • Prooph\EventStore\Pdo\MariaDbEventStore: MariaDB event store adapter
  • Prooph\EventStore\Pdo\MySqlEventStore: MySQL event store adapter
  • Prooph\EventStore\Pdo\PostgresEventStore: PostgreSQL event store adapter

Available facades

Installation

You can install prooph/laravel-package via Composer by adding "prooph/laravel-package": "^0.4" as requirement to your composer.json.

Service Provider

If you are using Laravel 5.5 or higher the package will automatically register itself. Otherwise you need to add Prooph\Package\ProophServiceProvider to your providers array. Then you will have access to the services above.

This package has configuration files which can be configured to your needs.

Deploy the prooph config files to add your configuration for the prooph components.

$ php artisan vendor:publish

Database

Setup your database migrations for the Event Store and Snapshot with:

$ php artisan make:migration create_event_stream_table

Update the class CreateEventStreamTable:

class CreateEventStreamTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        \Prooph\Package\Migration\Schema\EventStoreSchema::createSingleStream('event_stream', true);
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \Prooph\Package\Migration\Schema\EventStoreSchema::dropStream('event_stream');
    }
}

And now for the snapshot table.

$ php artisan make:migration create_snapshot_table

Update the class CreateSnapshotTable:

class CreateSnapshotTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        \Prooph\Package\Migration\Schema\SnapshotSchema::create('snapshot');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        \Prooph\Package\Migration\Schema\SnapshotSchema::drop('snapshot');
    }
}

Now it's time to execute the migrations:

$ php artisan migrate

Example

You have only to define your models (Entities, Repositories) and commands / routes. Here is an example config from the proophessor-do example app.

Define the aggregate repository, command route and event route for RegisterUser in config/prooph.php.

// add the following config in your config/prooph.php under the specific config key
return [
    'event_store' => [
        // list of aggregate repositories
        'user_collection' => [
            'repository_class' => \Prooph\ProophessorDo\Infrastructure\Repository\EventStoreUserCollection::class,
            'aggregate_type' => \Prooph\ProophessorDo\Model\User\User::class,
            'aggregate_translator' => \Prooph\EventSourcing\EventStoreIntegration\AggregateTranslator::class,
            'snapshot_store' => \Prooph\EventStore\Snapshot\SnapshotStore::class,
        ],
    ],
    'service_bus' => [
        'command_bus' => [
            'router' => [
                'routes' => [
                    // list of commands with corresponding command handler
                    \Prooph\ProophessorDo\Model\User\Command\RegisterUser::class => \Prooph\ProophessorDo\Model\User\Handler\RegisterUserHandler::class,
                ],
            ],
        ],
        'event_bus' => [
            'router' => [
                'routes' => [
                    // list of events with a list of projectors
                    \Prooph\ProophessorDo\Model\User\Event\UserWasRegistered::class => [
                        \Prooph\ProophessorDo\Projection\User\UserProjector::class
                    ],
                ],
            ],
        ],
    ],
];

Add the service container factories to config/dependencies.php.

// add the following config in your config/dependencies.php after the other factories
return [
    // your factories
    // Model
    \Prooph\ProophessorDo\Model\User\Handler\RegisterUserHandler::class => \Prooph\ProophessorDo\Container\Model\User\RegisterUserHandlerFactory::class,
    \Prooph\ProophessorDo\Model\User\UserCollection::class => \Prooph\ProophessorDo\Container\Infrastructure\Repository\EventStoreUserCollectionFactory::class,
    // Projections
    \Prooph\ProophessorDo\Projection\User\UserProjector::class => \Prooph\ProophessorDo\Container\Projection\User\UserProjectorFactory::class,
    \Prooph\ProophessorDo\Projection\User\UserFinder::class => \Prooph\ProophessorDo\Container\Projection\User\UserFinderFactory::class,
];

Here is an example how to call the RegisterUser command:

    /* @var $container \Illuminate\Container\Container */
    
    /* @var $commandBus \Prooph\ServiceBus\CommandBus */
    $commandBus = $container->make(Prooph\ServiceBus\CommandBus::class);

    $command = new \Prooph\ProophessorDo\Model\User\Command\RegisterUser(
        [
            'user_id' => \Rhumsaa\Uuid\Uuid::uuid4()->toString(),
            'name' => 'prooph',
            'email' => '[email protected]',
        ]
    );

    $commandBus->dispatch($command);

Here is an example how to get a list of all users from the example above:

    /* @var $container \Illuminate\Container\Container */
    $userFinder = $container->make(Prooph\ProophessorDo\Projection\User\UserFinder::class);

    $users = $userFinder->findAll();

Support

Contribute

Please feel free to fork and extend existing or add new plugins and send a pull request with your changes! To establish a consistent code quality, please provide unit tests for all your changes and may adapt the documentation.

License

Released under the New BSD License.

More Repositories

1

event-store

PHP 7.4 EventStore Implementation
PHP
548
star
2

service-bus

PHP Lightweight Message Bus supporting CQRS.
PHP
439
star
3

event-sourcing

Provides basic functionality for event sourced aggregates.
PHP
262
star
4

proophessor-do

prooph components in action
JavaScript
254
star
5

docker-files

Collection of prooph docker files
M4
249
star
6

proophessor-do-symfony

Symfony version of proophessor-do CQRS + Event Sourcing example app
JavaScript
170
star
7

event-store-client

PHP Event Store Client Implementation
PHP
113
star
8

pdo-event-store

PDO implementation of ProophEventStore http://getprooph.org
PHP
110
star
9

event-store-symfony-bundle

Event Store Symfony Bundle
PHP
108
star
10

service-bus-symfony-bundle

Symfony Bundle - PHP Lightweight Message Bus supporting CQRS
PHP
89
star
11

common

Common classes used across prooph components
PHP
85
star
12

proophessor

Exploring prooph components
PHP
84
star
13

micro

Functional prooph for microservices
PHP
53
star
14

micro-do

Microservice version of the famous proophessor-do event sourcing app
PHP
42
star
15

event-store-bus-bridge

Marry CQRS with Event Sourcing
PHP
37
star
16

message-flow-analyzer

Static code analyzer for message flow in a prooph powered project
PHP
30
star
17

event-store-http-client

PHP 7.2 Event Store HTTP Client Implementation
PHP
25
star
18

pdo-snapshot-store

PDO Snapshot Store
PHP
25
star
19

php-cs-fixer-config

PHP CS Fixer config for prooph components
PHP
24
star
20

event-store-mgmt-ui

Event Store Management UI
JavaScript
23
star
21

snapshot-store

Snapshot Store
PHP
20
star
22

snapshotter

Take aggregate snapshots with ease
PHP
19
star
23

event-store-http-api

Prooph EventStore HTTP API
PHP
18
star
24

documentation

CSS
17
star
25

standard-projections

Standard projections to use with Prooph EventStore
PHP
15
star
26

laravel-example

PHP
15
star
27

psr7-middleware

Consume prooph messages with a PSR7 middleware
PHP
14
star
28

link

Automated Workflow Processing
JavaScript
13
star
29

event-store-doctrine-adapter

[Deprecated] Doctrine Adapter for ProophEventStore
PHP
13
star
30

humus-amqp-producer

HumusAmqp Producer for Prooph Service Bus
PHP
12
star
31

annotations

Prooph Annotations
PHP
12
star
32

psb-http-producer

Http Message Producer for Prooph Service Bus using httplug
PHP
11
star
33

micro-cli

Command line interface to create prooph microservices
PHP
11
star
34

no-mvc

[experimental] No View, No Controller, Just a Model and a Bus
PHP
11
star
35

http-middleware

PSR compatible middleware to integrate prooph with a middleware dispatcher
PHP
11
star
36

psb-enqueue-producer

Enqueue Producer for Prooph Service Bus http://getprooph.org
PHP
10
star
37

docs

prooph docs
9
star
38

fun-facts-service

Microservice to fetch and serve fun facts about prooph repositories
PHP
8
star
39

event-store-benchmarks

Benchmarks for prooph event store
PHP
8
star
40

redis-event-store

Redis Adapter for ProophEventStore
8
star
41

psb-bernard-producer

Bernard Message Producer for Prooph Service Bus
PHP
8
star
42

event-store-flywheel-adapter

Flywheel Adapter for ProophEventStore http://getprooph.org
PHP
7
star
43

service-bus-zfc-rbac-bridge

Marry Service Bus with ZfcRbac
PHP
7
star
44

arangodb-snapshot-store

ArangoDb Snapshot Store implementation
PHP
7
star
45

snapshot-doctrine-adapter

[Deprecated] Doctrine Adapter for the Snapshot Store
PHP
6
star
46

processing

Deprecated package. Will be removed in 03/2016! Use:
PHP
6
star
47

psb-zeromq-producer

ZeroMQ Message Producer for Prooph Service Bus.
PHP
6
star
48

event-store-http-middleware

PSR-15 Event Store HTTP API middleware
PHP
6
star
49

event-store-mongodb-adapter

[Deprecated] MongoDB Adapter for ProophEventStore
PHP
6
star
50

event-store-redis-adapter

[Deprecated] Redis Adapter for ProophEventStore http://getprooph.org
PHP
5
star
51

event-store-adapter-benchmarks

[deprecated] Prooph EventStore Adapter Benchmarks
PHP
5
star
52

ProophServiceBusModule

[deprecated] ZF 2 Module for ProophServiceBus. Use:
PHP
5
star
53

mongodb-snapshot-store

MongoDB Snapshot Store implementation
PHP
4
star
54

snapshot-mongodb-adapter

[Deprecated] MongoDB Adapter for the Snapshot Store
PHP
4
star
55

prooph-pack

A prooph "pack" recipe for Symfony flex
4
star
56

snapshot-redis-adapter

[Deprecated] Redis Adapter for the Snapshot Store http://getprooph.org
PHP
4
star
57

httplug-event-store

HTTP event-store implementation talking with http-api
PHP
4
star
58

snapshot-memcached-adapter

[Deprecated] Memcached Adapter for the Snapshot Store
PHP
3
star
59

psb-kafka-producer

3
star
60

docs-template

CSS
3
star
61

event-store-bus-bridge-symfony-bundle

[deprecated] Event Store Bus Bridge Symfony Bundle
PHP
3
star
62

psb-gearman-producer

[deprecated] Gearman Message Producer for Prooph Service Bus
3
star
63

ProophEventStoreModule

[deprecated] ZF 2 Module for ProophEventStore. Use:
PHP
2
star
64

link-message-queue

Message Queue Module for prooph LINK
PHP
2
star
65

link-process-manager

Process configurator for prooph LINK
PHP
2
star
66

memcached-snapshot-store

Memcached Snapshot Store implementation
PHP
2
star
67

link-sql-connector

SQL connector module for prooph LINK
PHP
1
star
68

various-benchmarks

various benchmarks for decision making
1
star
69

link-app-core

Application core for prooph LINK
PHP
1
star
70

psb-php-resque-producer

[deprecated] php-resque message producer for Prooph Service Bus
PHP
1
star
71

event-store-zf2-adapter

[Abandoned] ZF2 DB Adapter for ProophEventStore
PHP
1
star
72

link-dashboard

Dashboard module for prooph LINK
PHP
1
star