문제

Bootstrap.php 파일을보다 정리하는 과정을 진행하고 있지만 모든 것을 별도의 정적 메소드에 넣은 후에는 색인 컨트롤러 이외의 페이지를로드 할 수 없습니다. 예를 들어 열려고한다면

http://localhost/zftutorial/login/index

나는 얻다

    Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception' with message 
'Invalid controller class ("Login_IndexController")' in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php:341 
Stack trace: #0 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php(255): 
Zend_Controller_Dispatcher_Standard->loadClass('IndexController') #1 C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Front.php(934): 
Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), 
Object(Zend_Controller_Response_Http)) #2 C:\Program 
Files\VertrigoServ\www\zftutorial\public\index.php(18): Zend_Controller_Front->dispatch() 
#3 C:\Program Files\VertrigoServ\www\zftutorial\public\index.php(138): Bootstrap::run() #4
 {main} thrown in C:\Program 
Files\VertrigoServ\www\library\Zend\library\Zend\Controller\Dispatcher\Standard.php on 
line 341

그리고 내 부트 스트랩 파일에서 컨트롤러가 발견되는 곳을 정의한 것 같습니다.

public static function setupFrontController()
{
    self::$frontController = Zend_Controller_Front::getInstance();
    self::$frontController->throwExceptions(true);
    self::$frontController->returnResponse(true);
    self::$frontController->setBaseUrl('/zftutorial');

    self::$frontController->setControllerDirectory(
        array(
            'default' => self::$root . '../application/controllers',
            'admin' => self::$root . '../application/controllers',
            'index' => self::$root . '../application/controllers',
            'login' => self::$root . '../application/controllers',
            'user' => self::$root . '../application/controllers'
        )
    );

    self::$frontController->setParam('registry', self::$registry);

}

아마도 라우팅으로 무언가를해야하지만 내 앱은 이전에 암시 적 라우팅과 잘 어울 렸습니다. 예를 들어 다른 컨트롤러도 잘 작동했습니다. 위의 오류의 원인은 무엇입니까? 테스트/찾기/수정하려면 어떻게해야합니까?

도움이 되었습니까?

해결책

스택 추적을보고 오류가 발생합니다 잘못된 컨트롤러 클래스 ( "login_indexController")

이것은 클래스 login_indexcontroller가 존재하지 않음을 시사합니다.

로그인 모듈의 컨트롤러 디렉토리에 indexcontroller.php라는 파일이 있어야합니다. 두 모듈에 동일한 이름의 컨트롤러가 없기 때문에 현재 가지고있는 구조는 작동하지 않습니다. 구조를 변경하십시오

self::$frontController->setControllerDirectory(
        array(
            'default' => self::$root . '../application/modules/default/controllers',
            'admin' => self::$root . '../application/modules/admin/controllers',
            'index' => self::$root . '../application/modules/index/controllers',
            'login' => self::$root . '../application/modules/login/controllers',
            'user' => self::$root . '../application/modules/user/controllers'
        )
    );

self :: $ root에서 indexcontroller.php를 만듭니다. '../application/modules/login/controllers 및 클래스를 login_indexcontroller라고하는지 확인하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top