I have a problem with module routing. I have 2 modules, Application and Admin. Each modules have indexAction as default action:
localhost/ --> Application/index
localhost/admin/ -> Admin/index
Admin/index works only with localhost/admin/index/
This problem happens when a module name starts with the letter "A". If I rename Admin to "Cars", localhost/cars/ works correctly!
the error is:
A 404 error occurred
The requested controller was unable to dispatch the request.
Controller:
Application\Controller\Application
No Exception available
This is module.config.php inside Application module:
<?php
return array(
'router' => array(
'routes' => array(
'Application' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/][:action/]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
),
'defaults' => array(
'controller' => 'Application\Controller\Application',
'action' => 'index',
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Application\Controller\Application' => 'Application\Controller\IndexController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'Application/Application/index' => __DIR__ . '/../view/Application/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'Application' => __DIR__ . '/../view',
),
),
);
?>
this is module.config.php inside Admin module:
<?php
return array(
'router' => array(
'routes' => array(
'Admin' => array(
'type' => 'Segment',
'options' => array(
'route' => '/admin/[:action/]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
),
'defaults' => array(
'controller' => 'Admin\Controller\AdminController',
'action' => 'index'
),
),
),
),
),
'controllers' => array(
'invokables' => array(
'Admin\Controller\AdminController' => 'Admin\Controller\AdminController'
),
),
'view_manager' => array(
'display_not_found_reason' => true,
'display_exceptions' => true,
'template_path_stack' => array(
'Admin' => __DIR__ . '/../view',
),
),
);
?>
IndexController.php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController
{
public function indexAction(){
}
}
AdminController.php
namespace Admin\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class AdminController extends AbstractActionController
{
public function indexAction()
{}
}
Anyone can help me?