如何添加简单的新路线

时间:2014-08-05 16:00:17

标签: php zend-framework2

我一直在修改module / Application / config / module.config.php并添加一个像这样的新文字路线......

    'routes' => array(

        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),

        'categories' => array(
            'type'    => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/categories',
                'defaults' => array(
                    'controller' => 'Application\Controller\Categories',
                    'action'     => 'index',
                ),
            ),
        ),
    )

并进一步将控制器添加到可调用数组....

'controllers' => array(
    'invokables' => array(
        'Application\Controller\Index' => 'Application\Controller\IndexController',
        'Application\Controller\Categories' => 'Application\Controller\CategoriesController'
    ),
),

然而,当我尝试转到url / categories时,我得到了404.新的Controller有效,命名正确并放在正确的文件夹中。

我错过了什么?

0 个答案:

没有答案