/** * Bootstrap * * @param array $config * @throws \rock\base\BaseException */ public static function bootstrap(array $config) { Trace::beginProfile(Trace::APP, Trace::TOKEN_APP_RUNTIME); static::$components = $config['components']; unset($config['components']); static::$config = $config; Container::registerMulti(static::$components); $response = static::$app->response; try { // Triggered at the beginning Event::trigger(static::className(), self::EVENT_BEGIN_APP); // Routing $route = static::$app->route; $route->response = $response; $route->run(); } catch (\Exception $e) { ErrorHandler::display($e, Log::CRITICAL, $response); } //var_dump(Trace::getTime(Trace::APP_TIME)); Trace::endProfile(Trace::APP, Trace::TOKEN_APP_RUNTIME); //var_dump(Trace::get('db.query'), Trace::get(\rock\helpers\Trace::APP)); // Triggered at the end Event::trigger(static::className(), self::EVENT_END_APP); $response->send(); }
<?php error_reporting(-1); if (version_compare(PHP_VERSION, '5.4.0', '<')) { die('need to use PHP version 5.4.x or greater'); } require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php'; defined('ROCK_DEBUG') or define('ROCK_DEBUG', true); defined('DS') or define('DS', DIRECTORY_SEPARATOR); \rock\Rock::$app = new \rock\Rock(); // catch error \rock\exception\ErrorHandler::register(); $config = (require dirname(__DIR__) . '/configs/configs.php'); // bootstrap application \rock\Rock::bootstrap($config);