Zend 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',
),
),
);
ここで何が欠けていますか?