Zend Framework 3教程错误专辑servicemanager

时间:2017-06-20 05:59:15

标签: zend-framework3

执行期间发生错误;请稍后再试。

其他信息:

Zend\ServiceManager\Exception\ServiceNotFoundException

Screen Shot

2 个答案:

答案 0 :(得分:0)

您未配置Database Adapter。这里的例子。把这段代码放在

'项目之路'

  

'项目路径'/ config / autoload / global.php

<?php


use Zend\Db\Adapter\AdapterAbstractServiceFactory;
use Zend\Db\Adapter\AdapterServiceFactory;

return [
    'db' => [
        'adapters' => [
            'dbAdapter' => [
                'driver' => 'Pdo_Mysql',
                'dsn' => "pgsql:host=127.0.0.1;dbname=DBNAME",
                'username' => 'USERNAME',
                'password' => 'PASSWORD',
        'driver_options' => [
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'"
        ],
            ]
        ],    
    ],
    'service_manager' => [
        'factories' => [
        ],
        'abstract_factories' => [
   Zend\Navigation\Service\NavigationAbstractServiceFactory::class,
            AdapterAbstractServiceFactory::class,
        ],
    ],
];

答案 1 :(得分:0)

Zend\Db\Adapter\AdapterInterface服务由zend-db组件注册。因此,请确保它已在config/modules.config.php(其中包含autoload文件夹,application.config.php等)中注册。请记住,此配置文件不是您的(相册)模块的配置文件。所以打开config/modules.config.php

return [
    'Zend\Form',
    'Zend\Db',    // Make sure it exists
    'Zend\Router',
    'Zend\Validator',
    /* ... */
],

如果此Zend\Db不存在,则在终端上运行以下命令

composer require zendframework/zend-db

如果您收到如下提示

  Please select which config file you wish to inject 'Zend\Db' into:

  [0] Do not inject
  [1] config/modules.config.php
  Make your selection (default is 0):

在这种情况下,使用1将其注册到config/modules.config.php

Remember this option for other packages of the same type? (y/N)

如果你得到如上所述的另一个提示,那么只需将y放在zf组件安装中进一步删除提示,就像这样。