【发布时间】:2013-05-19 07:44:53
【问题描述】:
我正在尝试在 Zend 2 中创建自定义用户模块,但在“Segment”和“Literal”中的路由出现问题。
我用谷歌搜索了很多,但没有找到解决方案。我的模块是“用户”:
当我尝试访问 URL siteurl/user/login or siteurl/user 时出现错误。
"The requested controller could not be mapped to an existing controller class."
我已经在“module\User\src\User\Controller\UserController”中有一个用户控制器。
我在module.config.php 中定义了路由。
return array(
'controllers' => array(
'invokables' => array(
'User\Controller\User' => 'User\Controller\UserController',
),
),
// The following section is new and should be added to your file
'router' => array(
'routes' => array(
'user' => array(
'type' => 'Literal',
'priority' => 1000,
'options' => array(
'route' => '/user',
'defaults' => array(
'controller' => 'user',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'login' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/login',
'defaults' => array(
'controller' => 'user',
'action' => 'login',
),
),
),
'authenticate' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/authenticate',
'defaults' => array(
'controller' => 'user',
'action' => 'authenticate',
),
),
),
'logout' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/logout',
'defaults' => array(
'controller' => 'user',
'action' => 'logout',
),
),
),
'register' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/register',
'defaults' => array(
'controller' => 'user',
'action' => 'register',
),
),
),
'changepassword' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/change-password',
'defaults' => array(
'controller' => 'user',
'action' => 'changepassword',
),
),
),
'changeemail' => array(
'type' => 'Literal',
'options' => array(
'route' => '/user/change-email',
'defaults' => array(
'controller' => 'user',
'action' => 'changeemail',
),
),
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
我在这里错过了什么?
【问题讨论】:
标签: php zend-framework2