这是我得到的错误。我正在从一本书中学习zf2,但是他们忘记说我应该把这段代码放在哪里(我尝试了几次尝试,但没有一次尝试过。) 这是我的module.config.php
<?php
return array(
'controllers' => array(
'invokables' => array(
'Users\Controller\Index' =>
'Users\Controller\IndexController',
'Users\Controller\Register' =>
'Users\Controller\RegisterController',
'Users\Controller\Login' =>
'Users\Controller\LoginController',
'Users\Controller\UserManager' =>
'Users\Controller\UserManagerController',
),
),
'router' => array(
'routes' => array(
'users' => array(
'type' => 'Literal',
'options' => array(
'route' => '/users',
'defaults' => array(
'__NAMESPACE__' => 'Users\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' =>
'/[:controller[/:action]]',
'constraints' => array(
'controller' =>
'[a-zA-Z][a-zA-Z0-9_-]*',
'action' =>
'[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(),
),
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'users' => __DIR__ . '/../view',
),
),
);
这应该在哪里?
'user-manager' => array(
'type' => 'Segment',
'options' => array(
'route' => '/User-manager[/:action[/:id]]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Users\Controller\UserManager',
'action' => 'index',
),
),
),
网址是
http://zend2.com/users/user-manager/edit/5
谢谢!
答案 0 :(得分:2)
它应该在'child_routes'
数组中而不是默认路由。取决于您是否应该使用它应该与'users'
同样在路线中,地址在用户管理器中以大写字母U写入,这是个案敏感所以你应该将你的地址写为http://zend2.com/users/User-manager/edit/5