2017-06-20 70 views

回答

0

沒有配置Database Adapter。這裏的例子。將這個代碼

'路徑工程'

'路徑工程'/配置/自動加載/ 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, 
     ], 
    ], 
]; 
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組件安裝這樣一個擺脫提示進一步。

相關問題