Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Several selectable DI Containers do not implement Interop\Container, causing an error in Zend Expressive 3 #608

Open
olger01 opened this issue Apr 3, 2018 · 2 comments
Labels

Comments

@olger01
Copy link

olger01 commented Apr 3, 2018

I set up a fresh installation of Zend Expressive 3 through the composer create-project command, and selected the following options:

  • Modular installation type
  • Symfony DI Container
  • FastRoute router
  • Zend-view template engine
  • Whoops error handler

Without adjusting anything within the project and accessing the project in my local development environment I'm faced with the following error:

Fatal error: Uncaught Zend\ServiceManager\Exception\InvalidArgumentException: Zend\ServiceManager\AbstractPluginManager expects a ConfigInterface or ContainerInterface instance as the first argument; received Symfony\Component\DependencyInjection\ContainerBuilder in /var/www/zend-expressive-skeleton/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php:59 Stack trace: #0 /var/www/zend-expressive-skeleton/vendor/zendframework/zend-view/src/HelperPluginManager.php(253): Zend\ServiceManager\AbstractPluginManager->__construct(Object(Symfony\Component\DependencyInjection\ContainerBuilder), Array) #1 /var/www/zend-expressive-skeleton/vendor/zendframework/zend-expressive-zendviewrenderer/src/HelperPluginManagerFactory.php(20): Zend\View\HelperPluginManager->__construct(Object(Symfony\Component\DependencyInjection\ContainerBuilder)) #2 /var/www/zend-expressive-skeleton/vendor/jsoumelidis/zend-sf-di-config/src/CallbackFactory.php(94): Zend\Expressive\ZendView\HelperPluginManagerFactory->__invoke(Object(Symfony\Com in /var/www/zend-expressive-skeleton/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 59

The problem seems to be that the application can not be instantiated as AbstractPluginManager (by extension by the HelperPluginManager) expects an instance of Interop\Container while Symfony\Component\DependencyInjection\ContainerBuilder does not implement this, but rather implements the Psr\Container\ContainerInterface directly.

This same problem also happens with both Pimple and Auryn, also selectable DI Containers. When I set up the project with the same modules, but select the default Zend DI Container it works just fine out of the box. I expected to see the same result when choosing the Symfony DI Container, Pimple, or Auryn in the configuration options, as the create project wizard leads me to believe these are supported DI Containers.

Some additional information, according to composer.lock:

  • zendframework/zend-expressive-skeleton version: 3.0.4
  • symfony/dependency-injection version: v4.0.7
  • container-interop/container-interop: 1.2.0

As a side note: I do not fully understand why the AbstractPluginManager expects an instance of Interop\Container since this is an interface which has been deprecated over a year ago in favour of the PSR-11 Container interface. DI Containers like Symfony, Pimple and Auryn have clearly already caught up with this. As Zend Expressive 3 is so new I expect it to use the PSR-11 interface for the best compatibility with up to date DI Containers.

@geerteltink geerteltink added the bug label Apr 3, 2018
@geerteltink
Copy link
Member

geerteltink commented Apr 3, 2018

DI Containers like Symfony, Pimple and Auryn have clearly already caught up with this. As Zend Expressive 3 is so new I expect it to use the PSR-11 interface for the best compatibility with up to date DI Containers.

zend-servicemanager uses PSR-11 as well. However the AbstractPluginManager is still not compatible with psr-11 containers. If I am not misstaken, it says that zend-view requires zend-servicemanager.
Until it is compatible, the solution is to use zend-servicemanager as the main container instead of symfony di or use twig or plates as the template renderer.

@weierophinney
Copy link
Member

This repository has been closed and moved to mezzio/mezzio; a new issue has been opened at mezzio/mezzio#9.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants