Zf2 路由问题

Zf2 Routing Issue

我是 Zend Framework 2 的新手。我已经下载了 zend-skeleton 应用程序,它正在工作 fine.but 当我创建新的相册模块并找不到调用相册路由页面时 error(404) 发生 .

我尝试应用多种类型的 zf2 路由,但出现相同的错误消息。

这是访问相册路径时反复显示的错误页面:

不知道为什么会出现这个错误?请给我任何解决方案?

尝试检查您的 Module.php 它应该看起来像这样

public function getConfig()
{
    return include __DIR__ . '/config/module.config.php';
}

public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
        ),
    );
}

特别检查所有模块文件中的命名空间 你的 module.config.php 应该是这样的

'controllers' => array(
    'invokables' => array(
        'index' => 'Album\Controller\IndexController',
    ),
),

'router' => array(
    'routes' => array(
        'album' => array(
            'type' => 'literal',
            'options' => array(
                'route'    => '/album',
                'defaults' => array(
                    'controller' => 'index',
                    'action'     => 'index',
                ),
            ),


        ),
    ),
),

'view_manager' => array(
    'template_path_stack' => array(
        'album' => __DIR__ . '/../view',
    ),
),

希望对你有所帮助