Solved

help with zend, handle 503 error

Posted on 2011-03-11
1
461 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Generating table dynamically is the most common issue faced by php developers.... So it seems there is a need of an article that explains the basic concept of generating tables dynamically. It just requires a basic knowledge of html and little maths…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

730 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