我挣扎的问题数天,但仍然没有找到什么地方错了。
这里是我的application.config.php配置段:
// Initial configuration with which to seed the ServiceManager.
// Should be compatible with Zend\ServiceManager\Config.
'service_manager' => array(
'abstract_factories' => array(
'Zend\Log\LoggerAbstractServiceFactory',
'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
)
),
'log' => array(
'Log\App' => array(
'writers' => array(
array(
'name' => 'stream',
'priority' => 1000,
'options' => array(
'stream' => 'data/logs/app.log'
)
)
)
)
)
我试图让服务实例在我的控制器:
$logger = $this->getServiceLocator()->get('Log\\App');
并抛出异常:
An error occurred
An error occurred during execution; please try again later.
Additional information:
Zend\ServiceManager\Exception\ServiceNotFoundException
File:
/var/openresty/html/skeleton-zf2/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:529
Message:
Zend\ServiceManager\ServiceManager::get was unable to fetch or create an instance for Log\App
更新谢谢你的帮助ocramius
我谨段module.config.php,它抛出的异常此时:
Zend\ServiceManager\Exception\ServiceNotCreatedException
File:
/var/openresty/html/skeleton-zf2/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:1070
Message:
An abstract factory could not create an instance of applicationweb(alias: Application\Web).