douyinghuo8874 2018-06-29 05:23
浏览 97

如何修复较新的zendframework的安装/升级?

From composer Install, I got newer version then the old Zend/Libeary, but got this error: atal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: Unable to resolve service "Router" to a factory; are you certain you provided it during configuration? in /home/azureuser/nginad/upload/vendor/zendframework/zend-servicemanager/src/ServiceManager.php:687 Stack trace: #0 /home/azureuser/nginad/upload/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(763): Zend\ServiceManager\ServiceManager->getFactory('Router') #1 /home/azureuser/nginad/upload/vendor/zendframework/zend-servicemanager/src/ServiceManager.php(200): Zend\ServiceManager\ServiceManager->doCreate('Router') #2 /home/azureuser/nginad/upload/vendor/zendframework/zend-mvc/src/Application.php(158): Zend\ServiceManager\ServiceManager->get('Router') #3 /home/azureuser/nginad/upload/vendor/zendframework/zend-mvc/src/Application.php(273): Zend\Mvc\Application->bootstrap(Array) #4 /home/azureuser/nginad/upload/public/index.php(28): Zend\Mvc\Application::init(Array) #5 {main} thrown in /home/azureuser/nginad/upload/vendor/zendframework/zend-servicemanager/src/ServiceManager.php on line 687

Install Screen...

Here is the folders where it’s installed under public

   Vendor
      Zendframework
          Zend-Mvc
              src
    ...

How to add Router to the configuration? Here is what I installed:

  • 写回答

2条回答 默认 最新

  • dqphg40600 2018-06-29 07:02
    关注

    I can not understand your query clearly but if you are struggling to add routes then you can add your route in module.config.php like below

    <?php
    use Zend\Router\Http\Literal;
    use Zend\Router\Http\Segment;
    
    return [
        'router' => [
            'routes' => [
                'home' => [
                    'type' => Literal::class,
                    'options' => [
                        'route'    => '/',
                        'defaults' => [
                            'controller' => Controller\IndexController::class,
                            'action'     => 'index',
                        ],
                    ],
                ],
                'application' => [
                    'type'    => Segment::class,
                    'options' => [
                        'route'    => '/application[/:action]',
                        'defaults' => [
                            'controller'    => Controller\IndexController::class,
                            'action'        => 'index',
                        ],
                    ],
                ],
            ],
        ],
    
      //...
    ];
    
    评论

报告相同问题?