|
| 1 | +# Installation |
1 | 2 |
|
2 | | -### Define your aggregates with class namespace and the table name |
| 3 | +If you are not using a symfony [flex](https://github.com/symfony/flex) |
| 4 | +or the [recipes](https://flex.symfony.com/) for it, |
| 5 | +then you have to carry out a few installation steps by hand. |
3 | 6 |
|
4 | | -Class `App\Domain\Profile\Profile` is from the [libraries example](https://github.com/patchlevel/event-sourcing#define-aggregates) and is using the table name `profile` |
| 7 | +## Require package |
5 | 8 |
|
| 9 | +The first thing to do is to install packet if it has not already been done. |
| 10 | + |
| 11 | +```bash |
| 12 | +composer require patchlevel/event-sourcing-bundle |
| 13 | +``` |
| 14 | + |
| 15 | +> :book: how to install [composer](https://getcomposer.org/doc/00-intro.md) |
| 16 | +
|
| 17 | +## Enable bundle |
| 18 | + |
| 19 | +Then we have to activate the bundle in the `config/bundles.php`: |
| 20 | + |
| 21 | +```php |
| 22 | +return [ |
| 23 | + Patchlevel\EventSourcingBundle\PatchlevelEventSourcingBundle::class => ['all' => true], |
| 24 | +]; |
| 25 | +``` |
| 26 | + |
| 27 | +If you don't have `config/bundles.php` then you need to add the bundle in the kernel: |
| 28 | + |
| 29 | +```php |
| 30 | +class AppKernel extends Kernel |
| 31 | +{ |
| 32 | + public function registerBundles() |
| 33 | + { |
| 34 | + $bundles = [ |
| 35 | + new Patchlevel\EventSourcingBundle\PatchlevelEventSourcingBundle(), |
| 36 | + ]; |
| 37 | + } |
| 38 | +} |
6 | 39 | ``` |
| 40 | + |
| 41 | +## Configuration file |
| 42 | + |
| 43 | +Now you have to add a minimal configuration file here `config/packages/patchlevel_event_sourcing.yaml`. |
| 44 | + |
| 45 | +```yaml |
7 | 46 | patchlevel_event_sourcing: |
8 | 47 | connection: |
9 | 48 | url: '%env(EVENTSTORE_URL)%' |
10 | | - store: |
11 | | - type: multi_table |
12 | | - aggregates: |
13 | | - profile: |
14 | | - class: App\Domain\Profile\Profile |
15 | 49 | ``` |
| 50 | +
|
| 51 | +## Dotenv |
| 52 | +
|
| 53 | +Finally we have to fill the ENV variable with a connection url. |
| 54 | +
|
| 55 | +```dotenv |
| 56 | +EVENTSTORE_URL: mysql://user:secret@localhost/app |
| 57 | +``` |
| 58 | +
|
| 59 | +> :book: You can find out more about what a connection url looks like [here](https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url). |
| 60 | +
|
| 61 | +Now you can go back to [getting started](https://github.com/patchlevel/event-sourcing-bundle#getting-started). |
0 commit comments