Skip to content

Instantly share code, notes, and snippets.

@fedek6

fedek6/web.php

Created May 21, 2018
Embed
What would you like to do?
Debug information about rendered template in Yii2
<?php
$config = [
'components' => [
'view' => [
'on afterRender' => function ($event) {
// Check if this is not a layout file
if( preg_match( '/layouts/', $event->viewFile ) == 0 ) {
/**
* Add template info.
*/
/** @var $event yii\base\ViewEvent */
$event->output = "<!-- @begin_view: {$event->viewFile} -->\n" . $event->output . "<!-- @end_view: {$event->viewFile} -->\n";
}
},
],
],
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment