将zf2迁移到zf3时出错。无法解决服务,

时间:2017-08-21 06:38:46

标签: php zend-framework2 zend-framework3

我正在将应用程序从zf2迁移到zf3。

一切都很好但是在使用“viewhelpermanager”的页面上,通过错误。

错误:"Unable to resolve service "viewhelpermanager" to a factory; are you certain you provided it during configuration?"

我已经检查过Zf2中有"viewhelpermanager"的服务配置。但在ZF3中找不到。

它在zf2中工作,但不在zf3中工作。

由于

1 个答案:

答案 0 :(得分:2)

根据文件。 “在第3版中,服务名称区分大小写,并且不会以任何方式进行标准化。”

在你的情况下,在zf2中有“viewhelpermanager”以及“ViewHelperManager”,现在在Zf3中,只有“ViewHelperManager”可用。

但是在Zf3中将以下行添加到Module.php中。

public function getServiceConfig()
    {
        return array(
            'aliases' => array(
                'viewhelpermanager' =>'ViewHelperManager'
             )
        );
    }

如果getServiceConfig()存在,则添加

 'aliases' => array(
                    'viewhelpermanager' =>'ViewHelperManager'
                 )

有关详情和详情,请参阅Flask-Script documentation