Creating Zend_Controllers
December 31st, 2008The last video in a series showing how to setup the Zend Framework from scratch. This video goes through the steps required to create a Zend_Controller for handling error reporting as well as creating the main IndexController. Zend_Layout is also briefly mentioned as part of the MVC setup.

Super screencast!
But maybe you will give us small link under video on current sources project, only your files without framework files.
@spirit:
thanks for the feedback! I’ll start posting my project files on the website.
hi i made every this as you did from fist video to this one and something is wrong when i open my page it prints layout()->content; ?> and nothing more what could be the problem?
Okay, I’m stuck. I’ve done all of the screencasts and everything has worked up to this point. My problem is occurring with the error controller. When I launch the page all I’m seeing is..
An error occured
Application error
and not the stack trace or request parameters. I’ve double checked all of the code and I just can’t find the error. Any help would be appreciated.
Thanks.
Hi Tader,
I would check the version of PHP that you’re running since it might be the case that you’re running PHP 4. To check this, add to the top of your index.php file and see. Good luck!
Hi Russ,
I would suggest that you look at your php_error.log file to see f there’s any errors popping up there. Also, it sounds like your dev environment is set to production and so errors are being hidden in the view. Look at error.phtml and put the stack outside of the if statement for env == development. Let me know if that works. Good luck!
Thanks for the reply. I moved everything out of the if statement and was able to see the exception information, message, stack trace, request parameters, but the it now says page not found at the top. Whenever I move anything back inside the if statement, it does not display on the server. I looked at the php_error.log, and couldn’t really get much from that.
the reason its not displaying is because you’re APPLICATION_ENVIRONMENT variable (a global that’s set in bootstrap.php or index.php) needs to be set to ‘dev’ or ‘development’.
if the page not found error is apache related, I would look to see that my .htaccess file is working properly.
if pages can’t be found after checking that, it could either be a routing issue or that the folder structure isn’t correct.
Haha!!! Thanks so much. It was a stupid simple typo that I just kept overlooking in the bootstrap file (‘APPLICATION_ENVIRONTMENT’, ‘development’). Thanks you helped me isolate where to look for the error. This is great now I can move on!!! Thanks!
I have an imac with eclipse pdt running on MAMP and a gateway laptop with eclipse pdt and WAMP. I am storing all of these files on a flash drive. Everything works fine on my imac through wamp, but when I go to the pc laptop with the flash drive the only thing that displays in firefox is:
layout()->content; ?>
Any ideas?
My problem was fixed by switching to XAMPP on the pc.
hmm, u said that we can get the env variable we set in bootstrap.php but what i am confused is that we have did
$frontController = Zend_Controller_Front::getInstance();
$frontController->getControllerDirectory(APPLICATION_PATH . “/controllers”);
$frontController->setParam(“env”, APPLICATION_ENVIRONMENT);
unset($frontController);
so $frontController is already unset? where did the variables we set go to? a static variable of the class? but am i right to say i can also do
Zend_Controller_Front::getInstance()->getControllerDirectory(APPLICATION_PATH . “/controllers”);
…
Zend_Controller_Front::getInstance()->setParam(“env”, APPLICATION_ENVIRONMENT);
but $frontController does not seem to be passed a reference of getInstance()?
If it displays “layout()->content; ?> ” then short_open_tag in php.ini is set to Off, you should set it to:
short_open_tag = On
@Anze
thanks man,
That’s working perfect.
I still have the same problem, When i run the index.php, i get the followings :
layout()->content; ?>
i switched from WAMP to XAMP , i also sat
; short_open_tag
; Default Value: On
; Development Value: On
; Production Value: On
but i still receive the same output, anyone can help ?
Where is the first video, I am like to start from the beginning with Zend.
thank you
Hey Qasim,
I would start with the Intro to Zend 1.8 video.
i have an error when i run index.php
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, admin@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log.
what is wrong? any idea?
thanks
i fixed =)
i uncomment this line in httpd.conf
LoadModule rewrite_module modules/mod_rewrite.so
i’am getting the following Fatal error: Uncaught exception ‘Zend_Controller_Dispatcher_Exception’ with message ‘Controller ‘ErrorController’ is not an instance of Zend_Controller_Action’ in C:\wamp\www\zc\library\Zend\Controller\Dispatcher\Standard.php:264 Stack trace: #0 C:\wamp\www\zc\library\Zend\Controller\Front.php(934): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\wamp\www\zc\public\index.php(35): Zend_Controller_Front->dispatch() #2 {main} thrown in C:\wamp\www\zc\library\Zend\Controller\Dispatcher\Standard.php on line 264
i can;t understand what’s wrong..