zend framework2 - ZF2 Route To Controller at Top Level -
please excuse newbiness zf2. want route controller top level...
in zf2 skeleton, it's setup route segmented after application :
http://www.example.com/application[/:controller[/:action]]
but not go thru application path , go controller :
http://www.example.com/[:controller[/:action]]
i've searched extensively couldn't work. have module.config.php setup follow:
/* in module.config.php */ 'router' => array( 'routes' => array( 'home' => array( 'type' => 'zend\mvc\router\http\literal', 'options' => array( 'route' => '/', 'defaults' => array( '__namespace__' => 'application\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( ), ), ), ), ), ), ), 'controllers' => array( 'invokables' => array( 'application\controller\index' => 'application\controller\indexcontroller', 'application\controller\login' => 'application\controller\logincontroller', ), ),
if browse http://www.example.com/login , says "the requested url not matched routing." think i'm missing fundamental concepts... =(
the child route gets concatenated parent route. means you're defining following possible route:
http://example.com//:controller/:action
notice double dipped forward slash. if child route parameters optional , namespace doesn't change, makes no sense define them child_route @ all, makes slower in end.
Comments
Post a Comment