我正在尝试开始使用 ZF2,当我从教程(在 ZF 网站上)编写代码时遇到问题。我的代码:
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
就可以了。我的问题是什么?:/