pushHandler(new \Whoops\Handler\PrettyPageHandler); $whoops->register(); // if (PHP_VERSION > 5.6) // set_error_handler([new BaseError(), 'handler']); // set_exception_handler([new BaseException(), 'handler']); $routeDriver = ''; if (php_sapi_name() == 'cli') { // 命令行运行程序 $routeDriver = new Command(); } else { // 其他方式 switch ($type) { case 1: $routeDriver = new Pathinfo(); break; default: // 其他 } } try { // 实例化路由 $route = new Router($routeDriver, $defaultAddress); $route->handler(); } catch (RouteException $route) { exit($route->handler()); } catch (DatabaseException $db) { exit($db->handler()); } } }