我尝试运行ZF2应用程序,而runnig收到错误“An exception was raised while creating "MvcTranslator
”;更新作曲家后没有返回实例。
我已在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 (Exception\ServiceNotFoundException $e) {
896: unset($circularDependencyResolver[$depKey]);
897: throw $e;
898: } catch (\Exception $e) {
899: unset($circularDependencyResolver[$depKey]);
900: throw new Exception\ServiceNotCreatedException(
901: sprintf('An exception was raised while creating "%s"; no instance returned', $rName),
902: $e->getCode(),
903: $e
904: );
任何人都可以帮助我摆脱这种情况,我一直在谷歌上搜索。
答案 0 :(得分:1)
我认为我没有最好的解决方案,但这可以避免错误。
使用翻译器对象创建服务。 编辑其中一个模块,添加服务 MvcTranslator 。例如,我编辑了我的 module / MyApplication / Module.php
namespace MyApplication
use Zend\I18n\Translator\Translator;
/* 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
答案 1 :(得分:0)
如果您使用的是Zend Framework 2.2或更高版本。
试试这个。
Comment out or remove
//use Zend\I18n\Translator\Translator; // comment out for ZF 2.2.0
//USE THIS for 2.2
use Zend\Mvc\I18n\Translator;` // comment in for ZF 2.2.0