Zend Framework - ErrorHandler doesn't seem to work properly

This is my first experience using the Zend Framework. I am trying to follow the Quick Start Guide . Everything worked as expected until I got to the Error Controller and View section. When I go to a page that does not exist, instead of getting an error page, I get a Fatal Error screen dump (in all its glory):

Fatal error: uncaught exception 'Zend_Controller_Dispatcher_Exception' with the message "Invalid controller specified (error)" in /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php:249 Stack trace: # 0 / home / .fantasia / bcnewman / foo.com / library / Zend / Controller / Front.php (946): Zend_Controller_Dispatcher_Standard-> submit (Object (Zend_Controller_Request_Http), Object (Zend_Controller_Response_Http)) # 1 / manfoo .com / public / index.php (42): Zend_Controller_Front-> dispatch () # 2 {main} is thrown at /home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php on line 249

I don’t think that this is caused by a syntax error on my part (the contents of the example file from the tutorial were copied and pasted), and I believe that the application directory structure is correct:

./application ./application/controllers ./application/controllers/IndexController.php ./application/controllers/ErrorHandler.php ./application/views ./application/views/scripts ./application/views/scripts/index ./application/views/scripts/index/index.phtml ./application/views/scripts/error ./application/views/scripts/error/error.phtml ./application/bootstrap.php ./public ./public/index.php 

And finally, the look of IndexController and index.phtml work.

+4
source share
2 answers

You have ErrorHandler.php. This should be ErrorController.php. All controllers must be named according to the format of NameController.php. Since you do not have his name properly, the dispatcher cannot find him.

+4
source

Assuming you have the ErrorController plugin loaded in your front controller, make sure that you do not have the following set in your bootstrap:

 $frontController->throwExceptions(true); 

If this value is set, Exceptions will always be thrown regardless of whether an error controller is installed.

+2
source

Source: https://habr.com/ru/post/1276838/


All Articles