Beispiel #1
0
 public static function getInstance()
 {
     if (!self::$_INSTANCE instanceof self) {
         self::$_INSTANCE = new self();
     }
     return self::$_INSTANCE;
 }
Beispiel #2
0
 /**
  *
  */
 public static function registerExceptionHandler($handlerCallback)
 {
     if (is_null($handlerCallback)) {
         $handlerCallback = array(get_class(), 'handleException');
     }
     // handle all exception
     self::$_oldExceptionhandler = set_exception_handler($handlerCallback);
     return self::$_oldExceptionhandler;
 }
Beispiel #3
0
 public static function run()
 {
     try {
         new Bootstrap();
         Zend_Controller_Front::getInstance()->dispatch();
         // catch exception
     } catch (Exception $e) {
         BaseZF_Error_Handler::printException($e);
     }
 }
Beispiel #4
0
}
try {
    // Register Error Handler to convert PHP error has Exception
    BaseZF_Error_Handler::registerErrorHandler();
    // Test Zend Framework Version
    BaseZF_Version::checkZendVersion(ZF_VERSION);
    // Initialize Application Configuration and Environment
    $application = new Zend_Application(APPLICATION_ENV, APPLICATION_CONFIG);
    $application->bootstrap();
    $application->run();
} catch (Exception $e) {
    // report error enable ?
    if (defined('DEBUG_REPORT') && DEBUG_REPORT) {
        BaseZF_Error_Handler::sendExceptionByMail($e, DEBUG_REPORT_FROM, DEBUG_REPORT_TO, DEBUG_REPORT_SUBJECT);
    }
    // debug error enable ?
    if (defined('DEBUG_ENABLE') && DEBUG_ENABLE) {
        BaseZF_Error_Handler::debugException($e);
        exit(1);
    }
    // then display Service Temporarily Unavailable
    ob_start();
    header("HTTP/1.1 503 Service Temporarily Unavailable");
    header("Status: 503 Service Temporarily Unavailable");
    header("Retry-After: 120");
    header("Connection: Close");
    echo file_get_contents('./unavailable.html');
    echo ob_get_clean();
    // Exit with error status
    exit(1);
}
Beispiel #5
0
<?php

/**
 * index.php
 *
 * Main Bootstrap
 *
 * @category   MyProject
 * @package    MyProject
 * @copyright  Copyright (c) 2008 MyProject
 * @author     Harold Thétiot (hthetiot)
 */
// launch ErrorHandler
BaseZF_Error_Handler::getInstance();
/**
 * Main BootStrap
 */
final class Bootstrap extends BaseZF_Bootstrap
{
    protected $_controllerModules = array('default', 'example');
    protected function _getRoutes()
    {
        return MyProject_Routes::fetch();
    }
}
// launch Bootstrap
Bootstrap::run();
Beispiel #6
0
 /**
  * Display error to end user and report it by mail if enable
  *
  * @return void
  */
 public function applicationerrorAction()
 {
     // get current config
     $config = MyProject::registry('config');
     // if report is enable sent exception info by mail
     if ($config->debug->report->enable) {
         BaseZF_Error_Handler::sendExceptionByMail($this->_error_handler->exception, $config->debug->report->from, $config->debug->report->to);
     }
 }