Zend_Framework

Zend Framework, IIS and 500 errors

One of the dangers of frameworks in general is that you forget that they do lots of handy things for you.

Consider Zend Framework’s default error controller:


   public function errorAction()
    {
        $errors $this->_getParam('error_handler');
        
        switch ($errors->type) {
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
            case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
        
                // 404 error -- controller or action not found
                $this->getResponse()->setHttpResponseCode(404);
                $this->view->message 'Page not found';
                break;
            default:
                // application error
                $this->getResponse()->setHttpResponseCode(500);
                $this->view->message 'Application error';
                break;
        }
        
        // Log exception, if logger available
        if ($log $this->getLog()) {
            $log->crit($this->view->message$errors->exception);
        }
        
        // conditionally display exceptions
        if ($this->getInvokeArg('displayExceptions') == true) {
            $this->view->exception $errors->exception;
        }
        
        $this->view->request   $errors->request;
    }

The error handler in ZF will catch any exceptions and route them to the error action in the error controller. This then sets the correct HTTP response code, logs the error and optionally displays it if a config setting is set.

Obviously on our production boxes, we don’t display the exceptions, but we do on our local development machines.

IIS has the concept of custom error pages that it displays when the app returns a 4xx or 5xx status code:
Screen shot 2010-03-04 at 10.07.41.png

There is also some settings for this page:
Screen shot 2010-03-04 at 10.28.06.png

By default this is set so that if you access the site using the localhost domain, then you’ll get the ZF error page and if you access the site remotely then you’ll get the IIS custom page and won’t see the error.

If, like me, you are developing with your IIS in a VM and using the host OS’s browser and developer tools, then you need to change the setting to “Detailed”:

detailed-iis-errors.png

Now you can see your exceptions and it doesn’t look like PHP has crashed :)

Author: Rob…

by News Robot on August 29, 2010 in News, No Comments »
tags: , , ,

COURSE: Zend Framework: Fundamentals

The Zend Framework: Fundamentals course is designed for experienced PHP programmers who want to learn to combine ZF concepts and structural elements to utilize the full power of this software development kit for PHP 5 applications.

The course helps you to learn by doing. Each discussion of related components is presented with examples of how best to utilize them in your applications, Hands-on exercises and the mini-projects you develop during the course reinforce the concepts you have learned. The online Zend Training Center allows participants to develop code during the course with your instructor able to see and coach your progress.

This course is offered online – with a live instructor – for 18 hours (9 – 2 hour sessions).

Author:
Source: Zend Events

by News Robot on August 29, 2010 in News, No Comments »
tags: ,

Netbeans 6.8 comes with support for Symfony framework , Zend framework

I know I don’t want any one to introduce about Netbeans . When I started my mini project in Java I was using notepad, vim etc . I was not aware about the IDE’s like Eclipse , Netbeans etc . Jose Antony was the person who introduced me wonderful IDE netbeans. Thanks to him .

Get Tomorrow Today with Netbeans IDE

read more

Author: hari

by News Robot on August 27, 2010 in News, No Comments »
tags: , , ,