DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Trending

  • RBAC With API Gateway and Open Policy Agent (OPA)
  • A Data-Driven Approach to Application Modernization
  • What Is JHipster?
  • JavaFX Goes Mobile
  1. DZone
  2. Coding
  3. Frameworks
  4. Zend Framework, IIS and 500 errors

Zend Framework, IIS and 500 errors

Rob Allen user avatar by
Rob Allen
·
May. 01, 11 · News
Like (0)
Save
Tweet
Share
8.80K Views

Join the DZone community and get the full member experience.

Join For Free

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 :)

Framework

Published at DZone with permission of Rob Allen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Trending

  • RBAC With API Gateway and Open Policy Agent (OPA)
  • A Data-Driven Approach to Application Modernization
  • What Is JHipster?
  • JavaFX Goes Mobile

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com

Let's be friends: