function exceptionHandler(Exception $exception) { profilerStop(); Log::exception($exception); if ($exception instanceof HttpException) { $response = $exception->toResponse(); $response->send(); return; } sendHttpStatus(500); header('content-type: application/json'); echo json_encode(['error_code' => 500, 'error_msg' => 'Server down, please check log!']); }
<?php define('ROOT_PATH', dirname(__DIR__)); if (empty($_FILES) && !empty($_SERVER['USE_SERVICE'])) { require ROOT_PATH . '/bootstrap/service.php'; } error_reporting(-1); include ROOT_PATH . '/bootstrap/functions.php'; //$_SERVER['ENABLE_PROFILER']=1; profilerStart(); include ROOT_PATH . '/bootstrap/start.php'; include ROOT_PATH . '/vendor/phwoolcon/di.php'; set_exception_handler('exceptionHandler'); set_error_handler('errorHandler'); $app = new Phalcon\Mvc\Application($di); $di->setShared('app', $app); Router::dispatch()->send(); profilerStop();