db->createCommand($sql)->queryOne(); if($queryRes !== false && $queryRes['pCount'] > 50) { echo 'Server Busy!'; exit; } //Change the UrlFormat for urlManager to get if a get request is given instead of a path format one. if (isset($_GET['r'])) { Yii::$app->urlManager->enablePrettyUrl = false; } else { // 2019-2-8 - TK: enable ob cache for better performance // 2019-4-18 - TK: it makes ERR_CONTENT_DECODING_FAILED error on chrome...comment out first /*$application->on(yii\web\Application::EVENT_BEFORE_REQUEST, function(yii\base\Event $event) { $event->sender->response->on(yii\web\Response::EVENT_BEFORE_SEND, function($e) { ob_start('ob_gzhandler'); }); $event->sender->response->on(yii\web\Response::EVENT_AFTER_SEND, function($e) { ob_end_flush(); }); });*/ /*$application->on(yii\web\Application::EVENT_BEFORE_REQUEST, function(yii\base\Event $event) { $event->sender->response->on(yii\web\Response::EVENT_BEFORE_SEND, function($e) { $response = $e->sender; if ($response->format === yii\web\Response::FORMAT_HTML) { if (!empty($response->data) && !YII_DEBUG) { //$response->data = compress($response->data); } if (!empty($response->content) && !YII_DEBUG) { //$response->content = compress($response->content); } } }); });*/ } // 2020-8-21 - TK: disable yii debug log completely - https://www.yiichina.com/tutorial/1065 // Yii::$app->log->targets['debug'] = null; Yii::$app->log->targets = []; $application->run();