symfony/web-profiler-bundle
Symfony WebProfilerBundle integrates the Symfony Profiler into your app, showing debug and performance insights via the web debug toolbar and profiler pages. Inspect requests, routes, logs, DB queries, caching, events, and more to troubleshoot faster.
Installation:
composer require symfony/web-profiler-bundle
Add to config/bundles.php (Symfony 5+):
return [
// ...
Symfony\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
];
Enable Debug Mode:
Set APP_DEBUG=true in .env (or config/packages/dev.php for Symfony 5+):
APP_DEBUG=1
APP_ENV=dev
First Use Case:
/ or run php bin/console server:run)./_profiler/).Debugging Requests:
Performance Profiling:
State Inspection:
Custom Data Collection:
// src/Collector/MyCustomCollector.php
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
class MyCustomCollector extends DataCollector {
public function collect(Request $request, Response $response, \Throwable $exception = null) {
$this->data['api_calls'] = $this->trackApiCalls();
return $this->data;
}
public function getName() { return 'my_custom'; }
}
config/packages/dev.php:
framework:
profiler:
collectors:
my_custom: App\Collector\MyCustomCollector
Integration with Tests:
Profiler::enable() in PHPUnit tests to capture profiler data:
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
class MyTest extends WebTestCase {
public function testSomething() {
$client = static::createClient();
$client->request('GET', '/');
$profiler = static::getContainer()->get('profiler');
$profiler->collect($client->getInternalRequest(), $client->getInternalResponse());
// Assertions using profiler data...
}
}
Debug Toolbar Not Showing:
APP_DEBUG=1 and APP_ENV=dev.php bin/console cache:clear./_profiler/* in production.Performance Overhead:
APP_DEBUG=0
--env=test for tests to avoid profiler noise.Doctrine Queries Missing:
doctrine:dbal or doctrine:orm is installed and configured.config/packages/dev/dbal.php:
dbal:
logging: true
Collector Conflicts:
time, router).Inspecting Twig Rendering:
Event Dispatcher Debugging:
Memory Leaks:
memory_get_usage() in PHP for granular tracking.Custom Data Visualization:
templates/bundles/webprofiler/ (Symfony 4+).Disabling Specific Collectors:
# config/packages/dev/profiler.yaml
framework:
profiler:
enabled: true
collectors:
'Symfony\Bundle\WebServerBundle\DataCollector\WebServerCollector': false
Profiler in Subrequests:
Renderer or HttpClient), but data is scoped to the parent request.Profiler::enable() explicitly for isolated subrequests.Production-Like Debugging:
APP_ENV=prod with APP_DEBUG=1 to test production configurations without toolbar noise./_profiler/ (disable in firewalls if needed):
security:
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
How can I help you explore Laravel packages today?