Reputation: 1
I'm a new user of Zend Framework and I have a project to do. The problem is that I can't configure my routes to a second controller. The first controller (Index) works perfectly but not the new one.
I created the module with zftool, so I have a module named "Medicaments" present. When I try to access my project with the following url localhost/project_zend/public (or localhost/project_zend/public/medicaments), it works and I arrive on my IndexController, indexAction. But when I try to access my new controller "ConfigurationController (present in /modules/Medicaments/Controller/), I arrive on a 404 page, saying that "The controller asked couldn't dispatch the request." and my view indicates that the controller used is "Medicaments/Controller/Index" and not "Medicaments/Controller/Configuration".
Here is my router configuration (in /modules/Medicaments/config/module.config.php) file:
'router' => array(
'routes' => array(
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Medicaments\Controller\Index',
'action' => 'index',
),
),
),
'medicaments' => array(
'type' => 'segment',
'options' => array(
'route' => '/medicaments[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'__NAMESPACE__' => 'Medicaments\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(
),
),
),
),
),
'configuration' => array(
'type' => 'segment',
'options' => array(
'route' => '/configuration[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Configuration',
'action' => 'index',
),
),
),
),
),
Thank you for your help.
Upvotes: 0
Views: 117
Reputation: 16455
Please work yourself through the official Documentation (here linked: Routing and Controllers).
Try to refrain from using tools when you do not know what they are doing. You'll only be hurting you in the long run, especially if things start to get tricky for you on the sprint already.
TL/DR: You have to create an invokables
-entry within the controllers
-configuration.
Upvotes: 1