ZF2:模块无法初始化 [英] ZF2: Module could not be initialized
本文介绍了ZF2:模块无法初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试开始使用 ZF2,但在编写教程中的代码(在 ZF 网站上)时遇到了问题.我的代码:
I'm trying to get started with ZF2 and I have a problem when I writting code from tutorial (on ZF website). My code:
Module.php:
<?php
namespace About;
class About
{
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
}
?>
config/module.config.php:
<?php
return array(
'controllers' => array(
'invokables' => array(
'About\Controller\About' => 'About\Controller\AboutController',
),
),
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/about[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'About\Controller\About',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'about' => __DIR__ . '/../view',
)
),
);
问题是:
Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (About) could not be initialized.' in /var/www/zend2/vendor/zendframework/zendframework/library/Zend/ModuleManager/ModuleManager.php on line 175
为什么它会在开始时显示?(在我的项目中:/var/www/zend2/).如果我从 application.config.php
中删除模块声明,它工作正常.我的问题是什么?:/
Why it's shown on start? (in my project: /var/www/zend2/). If I remove module declaration from application.config.php
it works okay. What is my problem? :/
推荐答案
哎呀,解决了!Module.php
中的类必须命名为Module
,而不是自己的名字...
Ouch, solved!
In Module.php
class must be named Module
, not own name...
这篇关于ZF2:模块无法初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文