mezzio / mezzio-skeleton

Laminas mezzio skeleton. Begin developing PSR-15 middleware applications in seconds!
https://docs.mezzio.dev/mezzio/
BSD 3-Clause "New" or "Revised" License
120 stars 31 forks source link

Fresh install with Symfony Container + zend-view got error #6

Closed weierophinney closed 4 years ago

weierophinney commented 4 years ago

Provide a narrative description of what you are trying to accomplish.

Code to reproduce the issue

  1. install fresh skeleton via command
composer create-project zendframework/zend-expressive-skeleton expressive3symfony

with choose the following options:

 What type of installation would you like?
  [1] Minimal (no default middleware, templates, or assets; configuration only)
  [2] Flat (flat source code structure; default selection)
  [3] Modular (modular source code structure; recommended)
  Make your selection (2): 
  - Copying src/App/ConfigProvider.php

  Which container do you want to use for dependency injection?
  [1] Aura.Di
  [2] Pimple
  [3] zend-servicemanager
  [4] Auryn
  [5] Symfony DI Container
  Make your selection or type a composer package name and version (zend-servicemanager): 5
  - Adding package jsoumelidis/zend-sf-di-config (^0.3)
  - Copying config/container.php

  Which router do you want to use?
  [1] Aura.Router
  [2] FastRoute
  [3] zend-router
  Make your selection or type a composer package name and version (FastRoute): 
  - Adding package zendframework/zend-expressive-fastroute (^3.0)
  - Whitelist package zendframework/zend-expressive-fastroute
  - Copying config/routes.php

  Which template engine do you want to use?
  [1] Plates
  [2] Twig
  [3] zend-view installs zend-servicemanager
  [n] None of the above
  Make your selection or type a composer package name and version (n): 3
  - Adding package zendframework/zend-expressive-zendviewrenderer (^2.0)
  - Whitelist package zendframework/zend-expressive-zendviewrenderer
  - Copying templates/error/404.phtml
  - Copying templates/error/error.phtml
  - Copying templates/layout/default.phtml
  - Copying templates/app/home-page.phtml

  Which error handler do you want to use during development?
  [1] Whoops
  [n] None of the above
  Make your selection or type a composer package name and version (Whoops): 1
  1. open browser

Expected results

Works.

Actual results

  1. open in browser, got 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 /Users/samsonasik/www/expressive3symfony/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 59

( ! ) 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 /Users/samsonasik/www/expressive3symfony/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 59

The issue seems in zend-view part with the following full call stack :


# | Time | Memory | Function | Location
-- | -- | -- | -- | --
1 | 0.0006 | 399680 | {main}( ) | .../index.php:0
2 | 0.0068 | 408920 | {closure:/Users/samsonasik/www/expressive3symfony/public/index.php:16-30}( ) | .../index.php:30
3 | 0.0323 | 696360 | Symfony\Component\DependencyInjection\ContainerBuilder->get( ) | .../index.php:21
4 | 0.0323 | 696360 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:536
5 | 0.0323 | 697136 | Symfony\Component\DependencyInjection\ContainerBuilder->createService( ) | .../ContainerBuilder.php:569
6 | 0.0327 | 697888 | call_user_func_array:{/Users/samsonasik/www/expressive3symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:1082} ( ) | .../ContainerBuilder.php:1082
7 | 0.0333 | 698760 | JSoumelidis\SymfonyDI\Config\CallbackFactory::createFactoryCallback( ) | .../ContainerBuilder.php:1082
8 | 0.0335 | 699280 | Zend\Expressive\Container\ApplicationFactory->__invoke( ) | .../CallbackFactory.php:56
9 | 0.0427 | 794016 | Symfony\Component\DependencyInjection\ContainerBuilder->get( ) | .../ApplicationFactory.php:39
10 | 0.0427 | 794016 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:536
11 | 0.0427 | 794040 | Symfony\Component\DependencyInjection\ContainerBuilder->createService( ) | .../ContainerBuilder.php:569
12 | 0.0428 | 794792 | call_user_func_array:{/Users/samsonasik/www/expressive3symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:1082} ( ) | .../ContainerBuilder.php:1082
13 | 0.0428 | 795216 | JSoumelidis\SymfonyDI\Config\CallbackFactory::createFactoryCallback( ) | .../ContainerBuilder.php:1082
14 | 0.0430 | 795736 | Zend\Expressive\Container\RequestHandlerRunnerFactory->__invoke( ) | .../CallbackFactory.php:56
15 | 0.0464 | 802712 | Symfony\Component\DependencyInjection\ContainerBuilder->get( ) | .../RequestHandlerRunnerFactory.php:44
16 | 0.0464 | 802712 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:536
17 | 0.0464 | 802736 | Symfony\Component\DependencyInjection\ContainerBuilder->createService( ) | .../ContainerBuilder.php:569
18 | 0.0465 | 803488 | call_user_func_array:{/Users/samsonasik/www/expressive3symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:1082} ( ) | .../ContainerBuilder.php:1082
19 | 0.0465 | 803912 | JSoumelidis\SymfonyDI\Config\CallbackFactory::createFactoryCallback( ) | .../ContainerBuilder.php:1082
20 | 0.0468 | 804464 | Zend\Expressive\Container\ServerRequestErrorResponseGeneratorFactory->__invoke( ) | .../CallbackFactory.php:56
21 | 0.0468 | 804464 | Symfony\Component\DependencyInjection\ContainerBuilder->get( ) | .../ServerRequestErrorResponseGeneratorFactory.php:25
22 | 0.0468 | 804464 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:536
23 | 0.0468 | 804488 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:552
24 | 0.0468 | 804488 | Symfony\Component\DependencyInjection\ContainerBuilder->createService( ) | .../ContainerBuilder.php:569
25 | 0.0469 | 805240 | call_user_func_array:{/Users/samsonasik/www/expressive3symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:1082} ( ) | .../ContainerBuilder.php:1082
26 | 0.0469 | 805664 | JSoumelidis\SymfonyDI\Config\CallbackFactory::createFactoryCallback( ) | .../ContainerBuilder.php:1082
27 | 0.0474 | 806184 | Zend\Expressive\ZendView\ZendViewRendererFactory->__invoke( ) | .../CallbackFactory.php:56
28 | 0.0516 | 884544 | Zend\Expressive\ZendView\ZendViewRendererFactory->injectHelpers( ) | .../ZendViewRendererFactory.php:76
29 | 0.0516 | 884544 | Zend\Expressive\ZendView\ZendViewRendererFactory->retrieveHelperManager( ) | .../ZendViewRendererFactory.php:107
30 | 0.0516 | 884544 | Symfony\Component\DependencyInjection\ContainerBuilder->get( ) | .../ZendViewRendererFactory.php:143
31 | 0.0516 | 884544 | Symfony\Component\DependencyInjection\ContainerBuilder->doGet( ) | .../ContainerBuilder.php:536
32 | 0.0517 | 884568 | Symfony\Component\DependencyInjection\ContainerBuilder->createService( ) | .../ContainerBuilder.php:569
33 | 0.0518 | 885320 | call_user_func_array:{/Users/samsonasik/www/expressive3symfony/vendor/symfony/dependency-injection/ContainerBuilder.php:1082} ( ) | .../ContainerBuilder.php:1082
34 | 0.0518 | 885744 | JSoumelidis\SymfonyDI\Config\CallbackFactory::createFactoryCallback( ) | .../ContainerBuilder.php:1082
35 | 0.0521 | 886264 | Zend\Expressive\ZendView\HelperPluginManagerFactory->__invoke( ) | .../CallbackFactory.php:56
36 | 0.0560 | 899200 | Zend\View\HelperPluginManager->__construct( ) | .../HelperPluginManagerFactory.php:20
37 | 0.0561 | 900704 | Zend\View\HelperPluginManager->__construct( ) | .../HelperPluginManager.php:253

Originally posted by @samsonasik at https://github.com/zendframework/zend-expressive-skeleton/issues/253

weierophinney commented 4 years ago

the possible solution probably unset the zend-view from templates option when container is not zend-servicemanager?


Originally posted by @samsonasik at https://github.com/zendframework/zend-expressive-skeleton/issues/253#issuecomment-385224328

weierophinney commented 4 years ago

I just tried all containers. zend-view works with Aura.Di and zend-servicemanager (and it used to work with the old pimple container adapter used in v1 and v2).

Disabling template options is complicated. It's easier to add a hint to the container config:

  Which container do you want to use for dependency injection?
  [1] Aura.Di
  [2] Pimple
  [3] zend-servicemanager (required for zend-view)
  [4] Auryn
  [5] Symfony DI Container
  Make your selection or type a composer package name and version (zend-servicemanager):

Would that work for you?


Originally posted by @geerteltink at https://github.com/zendframework/zend-expressive-skeleton/issues/253#issuecomment-385255883

weierophinney commented 4 years ago

Ok, that's seems fine, just wondering if "remember the selected container" is can be applied to be checked when view options shown


Originally posted by @samsonasik at https://github.com/zendframework/zend-expressive-skeleton/issues/253#issuecomment-385525448

weierophinney commented 4 years ago

I had the same issue with PHP-DI. I created a wrapper to enable Interop/Container. Check this link for more details: #25


Originally posted by @elie29 at https://github.com/zendframework/zend-expressive-skeleton/issues/253#issuecomment-436187212

weierophinney commented 4 years ago

@elie29 I don't think wrapping all containers to enable a deprecated interface is the right solution. It's better to update zend-view. Although I think the actual problem is with zend-servicemanager and its plugin manager. Once that is updated zend-view can be updated if it's still needed.


Originally posted by @geerteltink at https://github.com/zendframework/zend-expressive-skeleton/issues/253#issuecomment-436323600

michalbundyra commented 4 years ago

@samsonasik is is still an issue?

samsonasik commented 4 years ago

@michalbundyra I will check again in a few

samsonasik commented 4 years ago

Just tried re-install it, and it seems working now. I'm closing. thank you ;)