psr-container-messenger
psr-container-messenger copied to clipboard
bug: PHP-DI doesn't support factories with magic methods
Describe the bug
If someone uses mezzio + PHP-DI, they will receive an error MessageBusFactory::messenger.command.bus() is not a callable. A __call() or __callStatic() method exists but magic methods are not supported
.
PHP-DI uses PHP-DI/Invoker.
To Reproduce Steps to reproduce the behavior:
- Create project of Mezzio with PHP-DI container
- Add current library into the project
- Try to dispatch a command
- See error
Version of the xtreamwayz/psr-container-messenger
library
2.5.0
Expected behavior Command successfully dispatched.
How to fix it for yourself Use custom configuration entries for the factories or custom ConfigProvider
Hi @artemmolotov. First of all, it's good to see that mezzio is used with other containers than laminas-servicemanager. To be honest, I have never tried this with something else. This is certainly something that could be improved. I have no idea how to do this yet as the feature that the servicemanager provides makes configuration in such way pretty easy. But I agree that using custom configuration is not a user friendly way to use this library.
If I can ask, how exactly did you solve it?