Skip to content

Instantly share code, notes, and snippets.



Last active Sep 28, 2020
What would you like to do?
#concrete5 Visualize rendering time of each blocks with DebugBar
* First, install the debug bar package. @link:
* Then, add these code in your application/bootstrap/app.php
if ($app->isInstalled()) {
$director = $app->make(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class);
$debugBar = $app->make(\Concrete\Core\Package\PackageService::class)->getByHandle('concrete5_debugbar');
if (is_object($debugBar) && $debugBar->isPackageInstalled()) {
$director->addListener('on_block_load', static function ($event) use ($app) {
$bID = $event->getArgument('bID');
$btHandle = $event->getArgument('btHandle');
$app->make('debugbar/time')->startMeasure(sprintf('block_%d', $bID), sprintf('Rendering %s block (bID: %d)', $btHandle, $bID));
$director->addListener('on_block_output', static function ($event) use ($app) {
/** @var \Concrete\Core\Block\Block $b */
$b = $event->getBlock();
$bID = $b->getBlockID();
$app->make('debugbar/time')->stopMeasure(sprintf('block_%d', $bID), [
'arHandle' => $b->getAreaHandle(),
'cacheBlockOutput' => $b->cacheBlockOutput(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment