Php – Zend Framework – ErrorHandler does not seem to be working as expected

PHPzend-framework

This is my first experience using the Zend Framework. I am attempting to follow the Quick Start tutorial. Everything was working as expected until I reached the section on the Error Controller and View. When I navigate to a page that does not exist, instead of receiving the error page I get the Fatal Error screen dump (in all it's glory):

Fatal error: Uncaught exception 'Zend_Controller_Dispatcher_Exception'
with 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->dispatch(Object(Zend_Controller_Request_Http),
Object(Zend_Controller_Response_Http)) #1
/home/.fantasia/bcnewman/foo.com/public/index.php(42):
Zend_Controller_Front->dispatch() #2 {main} thrown in
/home/.fantasia/bcnewman/foo.com/library/Zend/Controller/Dispatcher/Standard.php
on line 249

I do not believe this is caused by a syntax error on my part (a copied and pasted the example file's content from the tutorial) and I believe I have the application directory structure 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 IndexController and index.phtml view does work.

Best Answer

You have ErrorHandler.php. It should be ErrorController.php. Controllers all need to be named following the format of NameController.php. Since you don't have it named properly the dispatcher cannot find it.

Related Topic