Example #1
0
     * 致命错误捕获
     */
    public static function fatalError()
    {
        if ($e = error_get_last()) {
            switch ($e['type']) {
                case E_ERROR:
                case E_PARSE:
                case E_CORE_ERROR:
                case E_COMPILE_ERROR:
                case E_USER_ERROR:
                    if (PHP_SAPI != 'cli') {
                        ob_end_clean();
                        if (SsdPHP::isDebug()) {
                            echo "\n\t\t\t\t\t\t<table border='1' cellpadding='3' style='font-size: 75%;border: 1px solid #000000;border-collapse: collapse;'><tr bgcolor='red'><td colspan='4' style='color: white'>fatalError!</td></tr><tr style='background-color: #ccccff; font-weight: bold; color: #000000;'> <th >type</th><th >File</th><th >Line</th><th >Message</th></tr><tr style='background-color: #cccccc; color: #000000;'><td>{$e['type']}</td><td>{$e['file']}</td><td>{$e['line']}</td><td>{$e['message']}</td></tr></table><hr style='background-color: #cccccc; border: 0px; height: 1px;' />";
                        }
                    }
                    break;
            }
        }
    }
}
if (SsdPHP::isDebug()) {
    RegShutdownEvent::add('SsdPHP\\Core\\Error::fatalError');
    set_error_handler('SsdPHP\\Core\\Error::error_handler', E_ALL);
    set_exception_handler('SsdPHP\\Core\\Error::exception_handler');
    //系统自定义日志
    if (class_exists('\\App\\Task\\controller\\systemLog')) {
        RegShutdownEvent::add('\\App\\Task\\controller\\systemLog::writeLog');
    }
}
Example #2
0
$rootpath = "";
if (is_file(__DIR__ . '/../../../../vendor/autoload.php')) {
    $rootpath = __DIR__ . '/../../../../';
    require $rootpath . 'vendor/autoload.php';
} elseif ($autoload = realpath(__DIR__ . "/../vendor/autoload.php")) {
    require $autoload;
}
if (!class_exists('\\SsdPHP\\SsdPHP')) {
    require dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . "SsdPHP" . DIRECTORY_SEPARATOR . "SsdPHP.php";
}
use SsdPHP\Core\RegShutdownEvent, SsdPHP\Core\Route, SsdPHP\Core\Error, SsdPHP\Core\Config, SsdPHP\Core\Language, SsdPHP\SsdPHP;
use SsdPHP\Pulgins\Session\Factory as Session;
SsdPHP::setRootPath($rootpath);
if (($r = SsdPHP::Bootstrap(function () {
    date_default_timezone_set('PRC');
    RegShutdownEvent::register();
    SsdPHP::setAppDir("App");
    SsdPHP::setDebug(true);
    Error::$CONSOLE = SsdPHP::isDebug();
    Config::load(SsdPHP::getRootPath() . DIRECTORY_SEPARATOR . 'config');
    Route::set(Config::getField('ROUTE', 'home', array()));
    Language::load();
    Session::Start($config = Config::get('SessionApiUser'));
})->Run()) === false) {
    header('HTTP/1.1 404 Not Found');
    header('Status: 404 Not Found');
    echo "404 error";
} else {
    echo $r;
}
$end = microtime(true);