gember / identity-generator-symfony
Gember Event Sourcing Identity Generator adapter based on symfony/uid
dev-main
2024-10-13 12:03 UTC
Requires
- php: ^8.3
- gember/event-sourcing: dev-main
- symfony/uid: ^7.1
Requires (Dev)
- captainhook/captainhook: ^5.23
- friendsofphp/php-cs-fixer: ^3.58
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^11.1
- rector/rector: ^1.2
- rregeer/phpunit-coverage-check: ^0.3.1
- shipmonk/composer-dependency-analyser: ^1.5
- symfony/property-access: ^7.1
This package is auto-updated.
Last update: 2024-12-13 12:21:24 UTC
README
Gember Event Sourcing Identity Generator adapter based on symfony/uid.
All external dependencies in Gember Event Sourcing are organized into separate packages, making it easy to swap out a vendor adapter for another.
Installation
Install with Composer:
composer require gember/identity-generator-symfony
Configuration
Bind this adapter to the IdentityGenerator
interface in your service definitions.
Examples
Vanilla PHP
use Gember\IdentityGeneratorSymfony\Ulid\SymfonyUlidIdentityGenerator; use Gember\IdentityGeneratorSymfony\Uuid\SymfonyUuidIdentityGenerator; use Symfony\Component\Uid\Factory\UlidFactory; use Symfony\Component\Uid\Factory\UuidFactory; # ULID Identity Generator $ulidIdentityGenerator = new SymfonyUlidIdentityGenerator( new UlidFactory(), ); # UUID (v4) Identity Generator $uuidIdentityGenerator = new SymfonyUuidIdentityGenerator( new UuidFactory(), );
Symfony
It is recommended to use the Symfony bundle to configure Gember Event Sourcing. With this bundle, the UUID adapter is automatically set as the default for Identity Generator.
If you're not using the bundle, you can bind it directly to the IdentityGenerator
interface.
# Bind ULID Identity Generator to interface Gember\EventSourcing\Util\Generator\Identity\IdentityGenerator: class: Gember\IdentityGeneratorSymfony\Ulid\SymfonyUlidIdentityGenerator arguments: - '@ Symfony\Component\Uid\Factory\UlidFactory' # OR bind UUID (v4) Identity Generator to interface Gember\EventSourcing\Util\Generator\Identity\IdentityGenerator: class: Gember\IdentityGeneratorSymfony\Uuid\SymfonyUuidIdentityGenerator arguments: - '@ Symfony\Component\Uid\Factory\UuidFactory'