1

我在 zend 框架中运行两个模块。1 是管理(后端),另一个是客户端(前端)。我为这两个模块分配了两个虚拟主机。后端工作正常。而且,在前端,我正在获取索引页面。但是当我试图在第二页上移动时,它给了我这样的错误:

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

这是我的 module.config.php 文件的主要部分......

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

在路由器中,这是第二页路由的代码..

'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',
                ),
            ),
        ),

我不知道,发生了什么事。帮助将不胜感激。

4

1 回答 1

1
'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',
                ),
            ),
        ),

如果它不起作用,请向我们展示module.php

于 2013-08-30T13:44:02.557 回答