Skip to content

Commit a3f5be1

Browse files
committed
Update readme with installation and configuration details
1 parent c61f376 commit a3f5be1

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,56 @@
22
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](LICENSE)
33
[![PHP Version](https://img.shields.io/badge/php-%5E8.3-8892BF.svg?style=flat)](http://www.php.net)
44

5-
Gember Identity generator ([gember/event-sourcing](https://github.com/GemberPHP/event-sourcing)) implementation based on [symfony/uid](https://github.com/symfony/uid).
5+
[Gember Event Sourcing](https://github.com/GemberPHP/event-sourcing) Identity Generator adapter based on [symfony/uid](https://github.com/symfony/uid).
6+
7+
> All external dependencies in Gember Event Sourcing are organized into separate packages,
8+
> making it easy to swap out a vendor adapter for another.
9+
10+
## Installation
11+
Install with Composer:
12+
```bash
13+
composer require gember/identity-generator-symfony
14+
```
15+
16+
## Configuration
17+
Bind this adapter to the `IdentityGenerator` interface in your service definitions.
18+
19+
### Examples
20+
21+
#### Vanilla PHP
22+
```php
23+
use Gember\IdentityGeneratorSymfony\Ulid\SymfonyUlidIdentityGenerator;
24+
use Gember\IdentityGeneratorSymfony\Uuid\SymfonyUuidIdentityGenerator;
25+
use Symfony\Component\Uid\Factory\UlidFactory;
26+
use Symfony\Component\Uid\Factory\UuidFactory;
27+
28+
# ULID Identity Generator
29+
$ulidIdentityGenerator = new SymfonyUlidIdentityGenerator(
30+
new UlidFactory(),
31+
);
32+
33+
# UUID (v4) Identity Generator
34+
$uuidIdentityGenerator = new SymfonyUuidIdentityGenerator(
35+
new UuidFactory(),
36+
);
37+
```
38+
39+
#### Symfony
40+
It is recommended to use the [Symfony bundle](https://github.com/GemberPHP/event-sourcing-symfony-bundle) to configure Gember Event Sourcing.
41+
With this bundle, the UUID adapter is automatically set as the default for Identity Generator.
42+
43+
If you're not using the bundle, you can bind it directly to the `IdentityGenerator` interface.
44+
45+
```yaml
46+
# Bind ULID Identity Generator to interface
47+
Gember\EventSourcing\Util\Generator\Identity\IdentityGenerator:
48+
class: Gember\IdentityGeneratorSymfony\Ulid\SymfonyUlidIdentityGenerator
49+
arguments:
50+
- '@ Symfony\Component\Uid\Factory\UlidFactory'
51+
52+
# OR bind UUID (v4) Identity Generator to interface
53+
Gember\EventSourcing\Util\Generator\Identity\IdentityGenerator:
54+
class: Gember\IdentityGeneratorSymfony\Uuid\SymfonyUuidIdentityGenerator
55+
arguments:
56+
- '@ Symfony\Component\Uid\Factory\UuidFactory'
57+
```

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gember/identity-generator-symfony",
3-
"description": "Gember Identity generator (gember/event-sourcing) implementation based on symfony/uid",
3+
"description": "Gember Event Sourcing Identity Generator adapter based on symfony/uid",
44
"license": "MIT",
55
"type": "library",
66
"keywords": [

0 commit comments

Comments
 (0)