loadPlugins(); // Global Error Handling for Dev Mode if (\App\Config\SiteConfig::IS_DEV) { // Catch Fatal Errors (Shutdown) register_shutdown_function(function() { $error = error_get_last(); if ($error && ($error['type'] === E_ERROR || $error['type'] === E_PARSE || $error['type'] === E_CORE_ERROR || $error['type'] === E_COMPILE_ERROR)) { // Convert to exception format for our helper $e = new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']); \App\Helpers\ErrorHelper::showException($e); } }); // Catch Uncaught Exceptions set_exception_handler(function($e) { \App\Helpers\ErrorHelper::showException($e); }); } // Define Routes require_once ROOT . '/routes/web.php'; require_once ROOT . '/routes/api.php'; // Dispatch // Dispatch try { $router->dispatch($_SERVER['REQUEST_URI'], $_SERVER['REQUEST_METHOD']); } catch (Exception $e) { if (\App\Config\SiteConfig::IS_DEV) { \App\Helpers\ErrorHelper::showException($e); } else { \App\Helpers\ErrorHelper::show(500, 'Internal Server Error', $e->getMessage()); } } catch (Error $e) { if (\App\Config\SiteConfig::IS_DEV) { \App\Helpers\ErrorHelper::showException($e); } else { \App\Helpers\ErrorHelper::show(500, 'System Error', $e->getMessage()); } }