Closed holtkamp closed 5 years ago
Thank you for your feedback.
I am using PHP-DI with zend framework and zend expressive with no issues. However, you may need container-interop as suggested by zend expressive if you want to use lazy or Abstract Factory.
I tried now the installation with composer serve and everything works correctly:
@elie29 thanks for the swift response. Will try again coming week and report back here. Probably I did something wrong 😉
It seems related to my preference to use zend-view
as template engine:
Which template engine do you want to use?
[1] Plates
[2] Twig
[3] zend-view installs zend-servicemanager
[n] None of the above
This involves zend-servicemanager
, which uses Interop\Container\ContainerInterface
in Zend\ServiceManager\AbstractPluginManager::__construct()
, at https://github.com/zendframework/zend-servicemanager/blob/release-2.7.11/src/AbstractPluginManager.php#L12
While the PHP-DI container implements Psr\Container\ContainerInterface
, see https://github.com/PHP-DI/PHP-DI/blob/6.0.5/src/Container.php#L29
Workarounds:
Interop\Container\ContainerInterface
instead of Psr\Container\ContainerInterface
Psr\Container\ContainerInterface
. This seems to be a "known" issue, see: https://github.com/zendframework/zend-servicemanager/issues/184Not sure whether a solution exists other then "waiting" zend-servicemanager
v4
...
@holtkamp thank you for the report.
I don't really use zend_view. However, zend-view involves zend-service-manager whose uses obsoleted interop-container.
Second, zend service acts as a container so I don't see the interest of using many containers in the same project.
I will close this issue as it is not related to this package we should wait zend service upgrade.
You need to decorate your PSR container for Interop container compatibility, see this comment
No need for a decorator. Aliasing with Psr container is enough
Until zend service manager release version 4, we have to wrap DI\Container by implementing Interop\Container\ContainerInterface
@holtkamp I released a new version with the wrapper would you please test https://github.com/elie29/zend-di-config/releases/tag/v3.0.9
@elie29 works perfectly! Very elegant approach, compliments 👍
@holtkamp thank you for testing the version. We can promote it now!
I have some experience with PHP-DI and now try to use it with Zend Expressive.
When using
composer create-project zendframework/zend-expressive-skeleton expressive-project
and selecting PHP-DI as DependencyInjectionContainer, the default installation seems to result in an error:composer serve
=> then open gives:I tried the instructions at https://github.com/elie29/zend-di-config#using-with-expressive
apparently
Interop\Container\ContainerInterface
is required byZend\ServiceManager\AbstractPluginManager::__construct()
, while the PHP-DI container implementsPsr\Container\ContainerInterface
.but am kind of stuck here... Any suggestions? Are the involved libraries still compatible?
Should Zend Expressive switch the the PSR-11 approach?
https://github.com/container-interop/container-interop