创建"MvcTranslator"时引发异常;未返回任何实例



我在运行ZF2应用程序时遇到错误"An exception was raised while creating "MvcTranslator";更新composer.后"未返回实例">

我已经在composer.json.中将最低需求参数从"minimum-stability": "stable"更改为"minimum-stability": "dev"

这是我的composer.json

{
"repositories": [
{
"type": "composer",
"url": "https://packages.zendframework.com/"
}
],
"homepage": "http://framework.zend.com/",
"require": {
"php": ">=5.3.3",
"zendframework/zendframework": "2.*",
"doctrine/doctrine-orm-module": "*",
"zendframework/zend-developer-tools": "dev-master",
"webino/zf2nette-debug": "dev-master",
"nitecon/zf2-db-session": "1.*",
"zf-commons/zfc-user": "*",
"nitecon/zfcuser-ldap": "dev-master",
"zf-commons/zfc-rbac":"dev-master"
},
"minimum-stability": "dev"
}

下面是堆栈错误。

try {
892:                $circularDependencyResolver[$depKey] = true;
893:                $instance = call_user_func($callable, $this, $cName, $rName);
894:                unset($circularDependencyResolver[$depKey]);
895:            } catch (ExceptionServiceNotFoundException $e) {
896:                unset($circularDependencyResolver[$depKey]);
897:                throw $e;
898:            } catch (Exception $e) {
899:                unset($circularDependencyResolver[$depKey]);
900:                throw new ExceptionServiceNotCreatedException(
901:                    sprintf('An exception was raised while creating "%s"; no instance returned', $rName),
902:                    $e->getCode(),
903:                    $e
904:                );

有谁能帮我摆脱困境吗?我一直在谷歌上搜索。

我认为我没有最好的解决方案,但这避免了错误。

使用转换器对象创建服务。编辑您的一个模块,添加服务MvcTranslator。例如,我编辑了模块/MyApplication/module.php

namespace MyApplication
use ZendI18nTranslatorTranslator;
/* Some other "use" */
class Module {
/* Code of module */
public function getServiceConfig() {
return array(
'factories' => array(
'MvcTranslator' => function($service) {
return new Translator();
},
/* Other services */
),
);
}

这对我有用,因为我没有使用翻译。如果您需要翻译,请检查以下内容:http://framework.zend.com/manual/2.2/en/modules/zend.i18n.translating.html

如果您使用的是Zend Framework 2.2或更高版本。

试试这个。

Comment out or remove 
//use ZendI18nTranslatorTranslator;     // comment out for ZF 2.2.0
//USE THIS for 2.2
use ZendMvcI18nTranslator;`         // comment in for ZF 2.2.0 

相关内容

  • 没有找到相关文章

最新更新