user231791
user231791

Reputation: 301

requested controller could not be mapped to an existing controller class

I am running two modules in zend framework. 1 is administration (backend) and another is client (frontend). I have allocated two virtual hosts for both modules. backend is working fine. And, in frontend I am getting the index page. but when I am trying to move on second page, it gives me error like:

A 404 error occurred

Page not found.

The requested controller could not be mapped to an existing controller class.
Controller:
Client\Controller\Search(resolves to invalid controller class or alias:       Client\Controller\Search)
No Exception available

Here is my main part of module.config.php file...

'controllers'  => array(
    'invokables' => array(
        'Client\Controller\Index'          => 'Client\Controller\IndexController',
        'Client\Controller\Search'         => 'Client\Controller\SearchController',
    ),
),

and in router this is the code for second page routing..

'search' => array(
            'type'    => 'segment',
            'options' => array(
                'route'       => '/search[/][:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults'    => array(
                    'controller' => 'Client\Controller\Search',
                    'action'     => 'index',
                ),
            ),
        ),

I don't know, what's going on. Help will be appreciated.

Upvotes: 1

Views: 14729

Answers (1)

Remi Thomas
Remi Thomas

Reputation: 1528

'controllers'  => array(
    // 
    'classes' => array(
        'Client\Controller\Index'          => 'Client\Controller\IndexController',
        'Client\Controller\Search'         => 'Client\Controller\SearchController',
    ),
    'invokables' => array(
        'Client\Controller\Index'          => 'Client\Controller\IndexController',
        'Client\Controller\Search'         => 'Client\Controller\SearchController',
    ),
),
'search' => array(
            'type'    => 'Segment', // <- I added S
            'options' => array(
                'route'       => '/search[/][:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults'    => array(
                    'controller' => 'Client\Controller\Search',
                    'action'     => 'index',
                ),
            ),
        ),

If it doesn't work, show us you module.php

Upvotes: 1

Related Questions