beberlei / litecqrs-php

Small convention based CQRS library for PHP
MIT License
553 stars 47 forks source link

[PLUGIN] [SYMFONY] Unable to find command_bus service #57

Closed jean-pasqualini closed 5 years ago

jean-pasqualini commented 5 years ago

h5. Description

Unable to find command_bus service because handler register after container builder remove unused service.

https://github.com/beberlei/litecqrs-php/blob/master/src/LiteCQRS/Plugin/SymfonyBundle/LiteCQRSBundle.php#L19

$container->addCompilerPass(new HandlerPass(), PassConfig::TYPE_AFTER_REMOVING);
In ContainerBuilder.php line 1013:

  [Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException]  
  You have requested a non-existent service "command_bus".                    

Exception trace:
 () at /project_dir/vendor/symfony/dependency-injection/ContainerBuilder.php:1013
 Symfony\Component\DependencyInjection\ContainerBuilder->getDefinition() at /project_dir/vendor/symfony/dependency-injection/ContainerBuilder.php:1049
 Symfony\Component\DependencyInjection\ContainerBuilder->findDefinition() at /project_dir/vendor/beberlei/lite-cqrs/src/LiteCQRS/Plugin/SymfonyBundle/DependencyInjection/Compiler/HandlerPass.php:13
 LiteCQRS\Plugin\SymfonyBundle\DependencyInjection\Compiler\HandlerPass->process() at /project_dir/vendor/symfony/dependency-injection/Compiler/Compiler.php:95
 Symfony\Component\DependencyInjection\Compiler\Compiler->compile() at /project_dir/vendor/symfony/dependency-injection/ContainerBuilder.php:748
 Symfony\Component\DependencyInjection\ContainerBuilder->compile() at /project_dir/vendor/symfony/http-kernel/Kernel.php:544
 Symfony\Component\HttpKernel\Kernel->initializeContainer() at /project_dir/vendor/symfony/http-kernel/Kernel.php:133
 Symfony\Component\HttpKernel\Kernel->boot() at /project_dir/vendor/symfony/framework-bundle/Console/Application.php:65
 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /project_dir/vendor/symfony/console/Application.php:145
 Symfony\Component\Console\Application->run() at /project_dir/bin/console:40

h5. Configuration used

lite_cqrs:
  monolog: true

I will propose a correction, I will leave you the pleasure of the returns