symfony
symfony copied to clipboard
[Messenger] requires [Notifier]
Symfony version(s) affected
5.4
Description
I tried to use the dependencies from a project I was working on, on a new empty one created with symfony new new_symfony_project --version="5.4.*" --webapp
and I've encountered some errors.
- create a "empty project" with the command mentioned above ( you can see composer.json at this stage here )
- new dependencies ( see composer.json here )
- run composer update
that triggered the following
Symfony operations: 11 recipes (be506038cff8a8c4aa1d535f1702c4eb)
- Configuring babdev/pagerfanta-bundle (>=v3.7.0): From auto-generated recipe
- WARNING liip/imagine-bundle (>=1.8): From github.com/symfony/recipes-contrib:main
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
Review the recipe at https://github.com/symfony/recipes-contrib/tree/main/liip/imagine-bundle/1.8
Do you want to execute this recipe?
[y] Yes
[n] No
[a] Yes for all packages, only for the current installation session
[p] Yes permanently, never ask again for this project
(defaults to n): p
- Configuring liip/imagine-bundle (>=1.8): From github.com/symfony/recipes-contrib:main
- Configuring oneup/flysystem-bundle (>=4.0): From github.com/symfony/recipes-contrib:main
- Configuring stof/doctrine-extensions-bundle (>=1.2): From github.com/symfony/recipes-contrib:main
- Configuring symfony/amazon-mailer (>=4.4): From github.com/symfony/recipes:main
- Configuring symfonycasts/reset-password-bundle (>=1.0): From github.com/symfony/recipes:main
- Configuring symfonycasts/verify-email-bundle (>=v1.12.0): From auto-generated recipe
- Configuring tgalopin/html-sanitizer-bundle (>=1.0): From github.com/symfony/recipes-contrib:main
- Unconfiguring symfony/notifier (>=5.0): From github.com/symfony/recipes:main
- Unconfiguring symfony/monolog-bundle (>=3.7): From github.com/symfony/recipes:main
- Unconfiguring symfony/messenger (>=5.4): From github.com/symfony/recipes:main
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In FrameworkExtension.php line 1960:
!!
!! Messenger support cannot be enabled as the Messenger component is not insta
!! lled. Try running "composer require symfony/messenger".
!!
!!
!!
Script @auto-scripts was called via post-update-cmd
- obviously I've required
symfony/messenger
which caused an error
Symfony operations: 1 recipe (2c7f3be9572170939089f7994f8cba0d)
- Configuring symfony/messenger (>=5.4): From github.com/symfony/recipes:main
Executing script cache:clear [KO]
[KO]
Script cache:clear returned with error code 1
!!
!! In FrameworkExtension.php line 2129:
!!
!! Invalid Messenger routing configuration: class or interface "Symfony\Compon
!! ent\Notifier\Message\ChatMessage" not found.
!!
!!
!!
Script @auto-scripts was called via post-update-cmd
with that being said - symfony/messenger
requires symfony/notifier
but it's not required as a dependency, hence I've created this pull request https://github.com/symfony/messenger/pull/17
Hopefully I have't made the wrong assumptions Thank you
How to reproduce
please see above
Possible Solution
No response
Additional Context
No response
Looking at your updated composer.json
file, you removed the symfony/messenger
dependency. Was that intended?
@xabbuh yes it was, I’m not using it
the reason behind all this fuss with changing composer.json is because I was trying to submit a bug report and didn’t want to publish my project, just my dependencies. but I was “hit” with this error.
You can see here the first error is due to messenger being enabled: https://github.com/symfony/symfony/blob/7616c8d586790c1d8d5e02421805153742dce90c/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L473-L474
and the second because your messenger configuration routes ChatMessage
s: https://github.com/symfony/symfony/blob/7616c8d586790c1d8d5e02421805153742dce90c/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php#L2127-L2130
So it seems the only issue here is that your messenger configuration was not removed on uninstall. Did you move it in a different file than the recipe?
Indeed, upon removing symfony/messenger
, this file should be removed: https://github.com/cybernet/new_symfony_project/blob/main/config/packages/messenger.yaml
If you remove symfony/notifier
, you should remove the specific routing for notifier messages in the messenger configuration: https://github.com/cybernet/new_symfony_project/blob/main/config/packages/messenger.yaml#L20-L21
When starting a project with the --webapp
flag, you'll get a set of configurations that is more opinionated and more dependent on all initial components to be available.
If you plan on removing quite a lot of the packages that come with --webapp
, I would recommend starting a project without this flag and requiring the specific Symfony packages that you need. In that way, the configuration is generated more modular and able to deal with e.g. the removal of one package.
For now, I consider this not a bug, but expected behavior. If you need any help with sorting out the configuration, feel free to use one of the community support channels of Symfony: https://symfony.com/support