配置以下错误后,我收到以下错误。
http://www.iprogrammerindia.in/crud-operations-zend-framework-2/
Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\InvalidServiceNameException'
with message 'An alias by the name "translator" or "translator" already exists'
in /opt/lampp/htdocs/crudapp/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:822
Stack trace:
#0 /opt/lampp/htdocs/crudapp/vendor/zendframework/zendframework/library/Zend/ServiceManager/Config.php(149): Zend\ServiceManager\ServiceManager->setAlias('translator', 'MvcTranslator')
#1 /opt/lampp/htdocs/crudapp/vendor/zendframework/zendframework/library/Zend/ModuleManager/Listener/ServiceListener.php(222): Zend\ServiceManager\Config->configureServiceManager(Object(Zend\ServiceManager\ServiceManager))
#2 [internal function]: Zend\ModuleManager\Listener\ServiceListener->onLoadModulesPost(Object(Zend\ModuleManager\ModuleEvent))
#3 /opt/lampp/htdocs/crudapp/vendor/zendframework/zendframework/library/Zend/EventManager/EventManager.php(468): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#4 /opt/lampp/htdocs/crudapp in /opt/lampp/htdocs/crudapp/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 822
答案 0 :(得分:0)
ZendSkeletonApplication
已defines translator as a factory:
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\Mvc\Service\TranslatorServiceFactory',
),
),
同一服务不能同时定义为别名和工厂。
您链接的教程适用于较早的ZendSkeletonApplication
,它将翻译器定义为别名
别名可以覆盖配置合并上的别名,因此不会导致任何错误。
要解决此问题,请从translator
module\Admin\config\module.config.php
别名声明