psr-container-messenger icon indicating copy to clipboard operation
psr-container-messenger copied to clipboard

bug: PHP-DI doesn't support factories with magic methods

Open artemmolotov opened this issue 3 years ago • 1 comments

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:

  1. Create project of Mezzio with PHP-DI container
  2. Add current library into the project
  3. Try to dispatch a command
  4. 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

artemmolotov avatar Aug 10 '21 20:08 artemmolotov

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?

geerteltink avatar Aug 11 '21 19:08 geerteltink