elao/profiler-dashboard-bundle
Symfony bundle that aggregates recent Symfony Profiler data (requests, timings, DB queries, etc.) into a single dashboard view, making it easier to compare and monitor performance across the last requests in dev/test environments.
Installation Add the bundle via Composer:
composer require elao/profiler-dashboard-bundle
Enable it in config/bundles.php:
Elao\ProfilerDashboardBundle\ElaoProfilerDashboardBundle::class => ['all' => true],
Configuration Publish the default config:
php artisan vendor:publish --provider="Elao\ProfilerDashboardBundle\ElaoProfilerDashboardBundle" --tag="config"
Verify config/elao_profiler_dashboard.php exists.
First Use Case
APP_DEBUG=true in .env)./_profiler and navigate to the "Profiler Dashboard" tab.max_requests in config).Monitoring Requests
execution_time, memory_usage).?_route=api.users.index).Integration with Existing Tools
monolog by configuring logger_channel in the bundle config.EventDispatcher to trigger alerts when thresholds (e.g., max_execution_time) are exceeded:
// In a service or listener
$this->eventDispatcher->addListener(
ElaoProfilerDashboardBundleEvents::REQUEST_PROFILED,
function (RequestProfiledEvent $event) {
if ($event->getExecutionTime() > 5000) {
// Trigger alert (e.g., Slack, Email)
}
}
);
Custom Metrics
// In a service or middleware
$profiler = $this->container->get('profiler');
$profiler->addCustomMetric('db_queries', $queryCount);
Performance Regression Testing
composer.json:
"autoload": {
"psr-4": {
"": "src/",
"Elao\\ProfilerDashboardBundle\\": "vendor/elao/profiler-dashboard-bundle/"
}
}
config/packages/dev/profiler.yaml:
framework:
profiler:
collect: true
config/elao_profiler_dashboard.php for prod):
return [
'max_requests' => 100, // Higher for production
'enabled' => false, // Disable in prod unless debugging
];
Deprecated Symfony Versions
symfony/polyfill or patch the bundle manually.Memory Overhead
max_requests) increases memory usage. Monitor with:
php artisan cache:clear && php artisan config:clear
max_requests to a reasonable limit (e.g., 50) in production.Profiler Disabled in Production
APP_DEBUG=false. Use a feature flag or middleware to enable it conditionally:
// In a middleware
if ($request->ip() === 'YOUR_IP' && !$this->container->getParameter('kernel.debug')) {
$this->container->setParameter('kernel.debug', true);
}
Database Backend Issues
database_connection in the config:
return [
'database_connection' => 'pgsql', // Override if not using default
];
Missing Dashboard Tab:
config/bundles.php.var/log/dev.log (Symfony’s default log location).APP_DEBUG=true).Metrics Not Updating:
php artisan cache:clear
profiler service is bound correctly in the container.Custom Metrics Not Displaying:
$profiler->addCustomMetric('key', $value); // Must be called during request lifecycle
Custom Storage Backend
elao_profiler_dashboard.storage:
# config/services.yaml
services:
App\Service\CustomProfilerStorage:
tags: ['elao_profiler_dashboard.storage']
Modify Metric Calculation
Elao\ProfilerDashboardBundle\Profiler\Profiler class to add/override metrics:
class CustomProfiler extends \Elao\ProfilerDashboardBundle\Profiler\Profiler
{
public function getCustomMetric()
{
return $this->customLogic();
}
}
config/services.yaml:
services:
Elao\ProfilerDashboardBundle\Profiler\Profiler:
class: App\Profiler\CustomProfiler
UI Customization
php artisan vendor:publish --provider="Elao\ProfilerDashboardBundle\ElaoProfilerDashboardBundle" --tag="templates"
templates/bundles/elaoprofilerdashboard/.How can I help you explore Laravel packages today?