{"id":22496994,"url":"https://github.com/morebec/orkestrasymfonybundle","last_synced_at":"2026-05-01T15:38:15.090Z","repository":{"id":74799766,"uuid":"238478681","full_name":"Morebec/OrkestraSymfonyBundle","owner":"Morebec","description":"[DEPRECATED] Integration Bundle of Orkestra for symfony projects. (use the morebec/orkestra-symfony-bundle instead)","archived":false,"fork":false,"pushed_at":"2020-12-21T21:38:21.000Z","size":130,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"v1.x","last_synced_at":"2025-02-01T23:45:16.084Z","etag":null,"topics":["orkestra","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Morebec.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-05T15:09:05.000Z","updated_at":"2021-04-21T01:15:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0cf5688-2fd9-4ee1-88aa-782e81252d4a","html_url":"https://github.com/Morebec/OrkestraSymfonyBundle","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FOrkestraSymfonyBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FOrkestraSymfonyBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FOrkestraSymfonyBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Morebec%2FOrkestraSymfonyBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Morebec","download_url":"https://codeload.github.com/Morebec/OrkestraSymfonyBundle/tar.gz/refs/heads/v1.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245925737,"owners_count":20694952,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["orkestra","symfony"],"created_at":"2024-12-06T20:15:21.648Z","updated_at":"2026-05-01T15:38:15.050Z","avatar_url":"https://github.com/Morebec.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Orkestra Symfony Bundle\nThis bundle integrates the Orkestra Framework with Symfony 5.\n\n[![Build Status](https://travis-ci.com/Morebec/OrkestraSymfonyBundle.svg?branch=v1.x)](https://travis-ci.com/Morebec/OrkestraSymfonyBundle)\n\n## Installation\n\n### Applications that use Symfony Flex\n\nOpen a command console, enter your project directory and execute:\n\n```console\n$ composer require morebec/orkestra-symfony-bundle\n```\n\n### Applications that don't use Symfony Flex\n\n#### Step 1: Download the Bundle\n\nOpen a command console, enter your project directory and execute the\nfollowing command to download the latest stable version of this bundle:\n\n```console\n$ composer require morebec/orkestra-symfony-bundle\n```\n\nThis command requires you to have Composer installed globally, as explained\nin the [installation chapter](https://getcomposer.org/doc/00-intro.md)\nof the Composer documentation.\n\n#### Step 2: Enable the Bundle\n\nThen, enable the bundle by adding it to the list of registered bundles\nin the `config/bundles.php` file of your project:\n\n```php\nreturn [\n    // ...\n    OrkestraSymfonyBundle::class =\u003e ['all' =\u003e true]\n];\n\n```\n\n#### Step 3: Add an Adapter\nFor persistence and infrastructure concerns, Orkestra requires adapters.\n\nInstall one of the adapters and register the classes of the adapter as services in a Module Configurator \n(see below for more information).\n \n## Usage\n\n### Creating a Module for a Bounded Context\nA Module is a logical separation of the source code. This is usually linked to the separations of DDD Bounded Contexts \naccording to the context map.\nAlthough Symfony provides a Bundle System, This bundle's Module System is tailored for the dependency injection needs  of Orkestra\nbased application. It provides ways to configure services using pure PHP with a fluent API which simplifies greatly this process\nwhile still allowing all the power of Symfony.\n\n#### Step 1: Create a configuration class for the Module\n1. Create a directory under `src` with the name of your Module. E.g. `Shipping'.\n2. Inside this directory, create a class implementing the `SymfonyOrkestraModuleConfiguratorInterface`.\nThis class will be used by the bundle to register the service dependencies of the module with Symfony's service container\nas well as the controller routes with the Symfony Route *(not to be confused with `DomainMessageRoutes`)*.\n```php\nclass SandboxModuleConfiguratorConfigurator implements SymfonyOrkestraModuleConfiguratorInterface\n{\n    public function configureContainer(ContainerConfigurator $container): void\n    {\n        $conf = new SymfonyOrkestraModuleContainerConfigurator($container);\n\n        $conf-\u003eservices()\n            -\u003edefaults()\n            -\u003eautowire()\n            -\u003eautoconfigure()\n        ;\n\n        $conf-\u003ecommandHandler(SandBoxMessageHandler::class)\n            -\u003eautoroute()\n            -\u003edisableMethodRoute('__invoke')\n        ;\n\n        $conf-\u003econsoleCommand(SandboxConsoleCommand::class);\n\n    }\n\n    public function configureRoutes(RoutingConfigurator $routes): void\n    {\n    }\n}\n```\n\u003e Note: The bundle provides a class `SymfonyOrkestraModuleContainerConfigurator` that allows to fluently define services.\n\u003e With a language closer to the technical requirements of Orkestra (eventHandler, commandHandler, queryHandler projectors etc.)\n\n#### Step 2: Enable the Module\nThen, enable the module by adding its Configurator to the list of registered Module Configurators in the `config/modules.php` file of your project:\n```php\nreturn [\n    // ...\n    SandboxModuleConfiguratorConfigurator::class =\u003e ['all' =\u003e true],\n];\n``` \n\u003e Module Configurations are registered just like Symfony Bundles allowing you to provide the environment in which they should exist.\n\u003e If you need a different configurator on a per environment basis, you can simply check for the environment using `$_ENV['APP_ENV]` in the configurators code.\n\n#### Step 3: Configure Adapter\nAs previously explained Orkestra requires adapters in order to support infrastructure concerns.\nThere adapters are not configured by this bundle since they might be various. Also, it does not forces to use an Event Store\nby default, meaning this should be configured.\n\nHere's an example configuration for the MongoDB Adapter:\n\n```php\n$configurator = new SymfonyOrkestraModuleContainerConfigurator($container);\n$configurator-\u003eservice(MongoDbClient::class)-\u003eargs(['%env(MONGO_URL)%', '%env(MONGO_DATABASE)%']);\n$configurator-\u003eservice(MongoDbTransactionMiddleware::class);\n$configurator-\u003eservice(DomainMessageSchedulerStorageInterface::class, MongoDbDomainMessageSchedulerStorage::class);\n$configurator-\u003eservice(PersonalInformationStoreInterface::class, MongoDbPersonalInformationStore::class);\n$configurator-\u003eservice(EventStoreInterface::class, SimpleEventStore::class);\n$configurator-\u003eservice(SimpleEventStorageReaderInterface::class, MongoDbSimpleEventStoreStorage::class);\n$configurator-\u003eservice(SimpleEventStorageWriterInterface::class, MongoDbSimpleEventStoreStorage::class);\n$configurator-\u003eservice(ProjectorStateStorageInterface::class, MongoDbProjectorStateStorage::class);\n```\n\n\u003e Note that the use of the `SymfonyOrkestraModuleContainerConfigurator` is optional and was just for demonstration purposes.\n\n### Adding Compiler Passes\nThe module configurator do not have a specific method to add compiler passes, instead, you can rely on the `ContainerConfigurator`\nto register custom `Container Extensions`. For more information on this please refer to the Official Symfony Documentation.\n\n### Configuring the Domain Message Bus\nThe `DomainMessageBusInterface` can be configured to receive more Middleware.\nThis Bundle provides a `DefaultDomainMessageBusConfigurator` that sets up the default Orkestra Middleware on the domain message bus.\nTo change the way it is wired, you can simply extend this class and register it in your dependency injection service configuration:\n```php\n// ...\n$container\n    -\u003eservices()\n    -\u003eset(DomainMessageBusConfiguratorInterface::class, YourCustomConfigurator::class);\n```\n\n#### Configuring the Domain Message Router\nConfiguring the router allows you to manually add new routes to the `DomainMessageRouterInterface`.\nSimply create a new class implementing `DomainMessageRouterConfiguratorInterface` registered with the service container\nand add your routes in the `configure` method. \n\nIf you use the `SymfonyOrkestraModuleContainerConfigurator` routes can be automatically added to the bus while registering\nmessage handlers.\n\n#### Configuring the Domain Message Normalizer\nThe message bus can be configured to receive more `NormalizerInterface` and `DenormalizerInterface` as per your needs.\nSimply create a new class implementing `DomainMessageNormalizerConfiguratorInterface` registered with the service container \nand add your `NormalizerInterface` and `DenormalizerInterface` in the `configure` method.\n\n### Adding Validators\nThe `SymfonyOrkestraModuleContainerConfigurator` provides a method to automatically register validators: \n`SymfonyOrkestraModuleContainerConfigurator::messageValidator`.\n\nThis is done behind the scene through tags and autowiring of tagged services.\n\nOrkestra does not provide a default implementation of a Validation library simply a set of interfaces.\nHere's an example of a validator using Symfony's Validator:\n\n```php\nclass SandboxCommandValidator implements DomainMessageValidatorInterface\n{\n    /**\n     * @var ValidatorInterface\n     */\n    private $validator;\n\n    public function __construct(ValidatorInterface $validator)\n    {\n        $this-\u003evalidator = $validator;\n    }\n\n    public function validate(DomainMessageInterface $domainMessage, DomainMessageHeaders $headers): DomainMessageValidationErrorList\n    {\n        /** @var SandboxCommand $command */\n        $command = $domainMessage;\n\n\n        $metadata = $this-\u003evalidator-\u003egetMetadataFor(SandboxCommand::class);\n        $metadata-\u003eaddPropertyConstraint('userId', new Assert\\NotBlank());\n\n        $errors = $this-\u003evalidator-\u003evalidate($command);\n\n        $c = (new Collection($errors))\n            -\u003emap(static function (ConstraintViolation $v) {\n                return new DomainMessageValidationError($v-\u003egetMessage(), $v-\u003egetPropertyPath(), $v-\u003egetInvalidValue());\n            })\n            -\u003eflatten()\n        ;\n\n        return new DomainMessageValidationErrorList($c);\n    }\n\n    public function supports(DomainMessageInterface $domainMessage, DomainMessageHeaders $headers): bool\n    {\n        return $domainMessage instanceof SandboxCommand;\n    }\n}\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Forkestrasymfonybundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmorebec%2Forkestrasymfonybundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmorebec%2Forkestrasymfonybundle/lists"}