Solved

help with zend, handle 503 error

Posted on 2011-03-11
1
452 Views
Last Modified: 2012-05-11
I need to point a 503 error to an error controller that returns a 503 header


Does this look right?

class Errorhandler_Outage extends ZEND_Controller_Action {

      /**
      * errorAction
      */
      public function errorAction(){
                           
            throw new Zend_Controller_Action_Exception(
                  $e->getMessage(), 503);
            }
           
      }
}
0
Comment
Question by:adybee
1 Comment
 
LVL 1

Accepted Solution

by:
DennisBecker earned 500 total points
ID: 35330740
This won't return a header with HTTP status code 503. You should use the default ErrorController where you can set the status code in the response object like the following:
 
<?php

class ErrorController extends Zend_Controller_Action
{

    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;
        }
}

Open in new window

Within the switch/case, you can change the default status code 500 to 503 and all should be fine.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
PHP Healthcheck 2 81
WordPress TK Title 8 23
PHP - AJAX and MySQL it works only if the value is a number 12 33
is this a cms? 8 32
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now