php - Zend Framework 2 Routing Error -
i trying create custom user module in zend 2, having problem in routing in "segment" , "literal".
i have googled lot without finding solution. module "user":
i getting error when try access url siteurl/user/login or siteurl/user
.
"the requested controller not mapped existing controller class."
i have user controller in "module\user\src\user\controller\usercontroller".
i have defined route in module.config.php.
return array( 'controllers' => array( 'invokables' => array( 'user\controller\user' => 'user\controller\usercontroller', ), ), // following section new , should added 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', ), ), );
what missing here?
your routes have no default '__namespace__'
key defined, router doesn't know controller named user
// following section new , should added file 'router' => array( 'routes' => array( 'user' => array( 'type' => 'literal', 'priority' => 1000, 'options' => array( 'route' => '/user', 'defaults' => array( // add namespace '__namespace__' => 'user\controller' 'controller' => 'user', 'action' => 'index', ), ), // .. ), ), ),
Comments
Post a Comment