Class yii\debug\controllers\DefaultController
Inheritance | yii\debug\controllers\DefaultController » yii\web\Controller |
---|---|
Available since extension's version | 2.0 |
Source Code | https://github.com/yiisoft/yii2-debug/blob/master/src/controllers/DefaultController.php |
Debugger controller provides browsing over available debug logs.
See also yii\debug\Panel.
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$layout | yii\debug\controllers\DefaultController | ||
$module | yii\debug\Module | Owner module. | yii\debug\controllers\DefaultController |
$summary | array | The summary data (e.g. URL, time) | yii\debug\controllers\DefaultController |
Public Methods
Method | Description | Defined By |
---|---|---|
actionDownloadMail() | Download mail action | yii\debug\controllers\DefaultController |
actionIndex() | Index action | yii\debug\controllers\DefaultController |
actionToolbar() | Toolbar action | yii\debug\controllers\DefaultController |
actionView() | yii\debug\controllers\DefaultController | |
actions() | yii\debug\controllers\DefaultController | |
beforeAction() | yii\debug\controllers\DefaultController | |
loadData() | yii\debug\controllers\DefaultController |
Protected Methods
Method | Description | Defined By |
---|---|---|
getManifest() | yii\debug\controllers\DefaultController |
Property Details
Method Details
Download mail action
public \yii\console\Response|\yii\web\Response actionDownloadMail ( $file ) | ||
$file | string | |
throws | \yii\web\NotFoundHttpException |
---|
public function actionDownloadMail($file)
{
$filePath = Yii::getAlias($this->module->panels['mail']->mailPath) . '/' . basename($file);
if ((mb_strpos($file, '\\') !== false || mb_strpos($file, '/') !== false) || !is_file($filePath)) {
throw new NotFoundHttpException('Mail file not found');
}
return Yii::$app->response->sendFile($filePath);
}
Index action
public string actionIndex ( ) | ||
throws | \yii\web\NotFoundHttpException |
---|
public function actionIndex()
{
$searchModel = new Debug();
$dataProvider = $searchModel->search($_GET, $this->getManifest());
// load latest request
$tags = array_keys($this->getManifest());
if (empty($tags)) {
throw new \Exception("No debug data have been collected yet, try browsing the website first.");
}
$tag = reset($tags);
$this->loadData($tag);
return $this->render('index', [
'panels' => $this->module->panels,
'dataProvider' => $dataProvider,
'searchModel' => $searchModel,
'manifest' => $this->getManifest(),
]);
}
Toolbar action
public string actionToolbar ( $tag ) | ||
$tag | string | |
throws | \yii\web\NotFoundHttpException |
---|
public function actionToolbar($tag)
{
$this->loadData($tag, 5);
return $this->renderPartial('toolbar', [
'tag' => $tag,
'panels' => $this->module->panels,
'position' => 'bottom',
'defaultHeight' => $this->module->defaultHeight,
]);
}
See also yii\debug\Panel.
public mixed actionView ( $tag = null, $panel = null ) | ||
$tag | string|null |
Debug data tag. |
$panel | string|null |
Debug panel ID. |
return | mixed |
Response. |
---|---|---|
throws | \yii\web\NotFoundHttpException |
if debug data not found. |
public function actionView($tag = null, $panel = null)
{
if ($tag === null) {
$tags = array_keys($this->getManifest());
$tag = reset($tags);
}
$this->loadData($tag);
if (isset($this->module->panels[$panel])) {
$activePanel = $this->module->panels[$panel];
} else {
$activePanel = $this->module->panels[$this->module->defaultPanel];
}
if ($activePanel->hasError()) {
Yii::$app->errorHandler->handleException($activePanel->getError());
}
return $this->render('view', [
'tag' => $tag,
'summary' => $this->summary,
'manifest' => $this->getManifest(),
'panels' => $this->module->panels,
'activePanel' => $activePanel,
]);
}
public void actions ( ) |
public function actions()
{
$actions = [];
foreach ($this->module->panels as $panel) {
$actions = array_merge($actions, $panel->actions);
}
return $actions;
}
public void beforeAction ( $action ) | ||
$action | ||
throws | \yii\web\BadRequestHttpException |
---|
public function beforeAction($action)
{
Yii::$app->response->format = Response::FORMAT_HTML;
return parent::beforeAction($action);
}
protected array getManifest ( $forceReload = false ) | ||
$forceReload | boolean |
protected function getManifest($forceReload = false)
{
if ($this->_manifest === null || $forceReload) {
if ($forceReload) {
clearstatcache();
}
$this->_manifest = $this->module->logTarget->loadManifest();
}
return $this->_manifest;
}
public void loadData ( $tag, $maxRetry = 0 ) | ||
$tag | string |
Debug data tag. |
$maxRetry | integer |
Maximum numbers of tag retrieval attempts. |
throws | \yii\web\NotFoundHttpException |
if specified tag not found. |
---|
public function loadData($tag, $maxRetry = 0)
{
// retry loading debug data because the debug data is logged in shutdown function
// which may be delayed in some environment if xdebug is enabled.
// See: https://github.com/yiisoft/yii2/issues/1504
for ($retry = 0; $retry <= $maxRetry; ++$retry) {
$manifest = $this->getManifest($retry > 0);
if (isset($manifest[$tag])) {
$data = $this->module->logTarget->loadTagToPanels($tag);
$this->summary = $data['summary'];
return;
}
sleep(1);
}
throw new NotFoundHttpException("Unable to find debug data tagged with '$tag'.");
}