0
我想在Zend 2中創建一個自定義用戶模塊,但我在「段」和「文字」路由中遇到問題。Zend Framework 2路由錯誤
我已經搜索了很多,但沒有找到解決方案。我的模塊是「用戶」:
當我嘗試訪問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',
),
),
);
我在這裏錯過了什麼?
工程:)控制器。大。謝謝 – shail
另一種方法是使用命名控制器。即命名可調用的用戶 – Sam