symfony/debug-pack
Symfony Debug Pack installs and configures tools for debugging and profiling Symfony apps in dev/test, including the Web Profiler, DebugBundle, and VarDumper. Helps inspect requests, performance, logs, and errors during development.
Installation:
composer require symfony/debug-pack
This installs the webprofilerbundle and stopwatch components, along with the debug-toolbar for Symfony applications.
Enable in config/bundles.php:
return [
// ...
Symfony\Bundle\DebugBundle\DebugBundle::class => ['all' => true],
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true],
];
First Use Case:
dev environment (APP_ENV=dev).Debugging Routes/Requests:
Performance Profiling:
App\Http\Controllers\*).App\Http\Middleware\*).Database Debugging:
N+1 queries or slow joins.Exception Tracking:
Symfony\Component\HttpKernel\Exception\NotFoundHttpException).Event Dispatching:
Illuminate\Auth\Events\Registered) with payloads.laravel-debugbar for deeper Laravel integration (e.g., Eloquent queries, Blade templates).dd() or dump() in controllers—variables appear in the Variables tab.WebProfilerBundle's DataCollector interface).use Symfony\Component\HttpKernel\DataCollector\DataCollector;
class CustomDataCollector implements DataCollector {
public function collect(Request $request, Response $response, \Exception $exception = null) {
// Add your data to $this->data.
}
public function getName() { return 'custom'; }
public function getTemplate() { return '@WebProfiler/Collector/custom.html.twig'; }
}
config/packages/dev.php:
web_profiler:
collectors:
custom: App\CustomDataCollector
Performance Overhead:
dev environment only).Doctrine-Only Database Tab:
laravel-debugbar or log queries manually:
DB::enableQueryLog();
// ... run queries ...
dd(DB::getQueryLog());
Caching Conflicts:
php artisan cache:clear
php artisan config:clear
Toolbar Not Showing:
APP_ENV=dev and APP_DEBUG=true in .env.config/bundles.php for correct bundle loading.TrustProxies) blocks the toolbar’s headers.CSRF Token Issues:
VerifyCsrfToken middleware:
protected $except = [
'/_profiler*',
'/_wdt*',
];
Inspect Headers:
Access-Control-Allow-Origin).Cache-Control).AppServiceProvider:
public function boot() {
header('X-Custom-Header: value');
}
Variable Dumping:
dump() or dd() in controllers—variables appear in the Variables tab.toArray() or json() to serialize:
dump($user->toArray());
Network Tab:
Custom Profiler Data:
DataCollector to add tabs (e.g., for queue jobs, cache hits).class QueueDataCollector implements DataCollector {
public function collect(Request $request, Response $response) {
$this->data['jobs'] = [
'processed' => Queue::size(),
'failed' => FailedJob::count(),
];
}
// ... getName(), getTemplate() ...
}
Override Templates:
resources/views/vendor/web-profiler/.{# resources/views/vendor/web-profiler/collector/time.html.twig #}
{% for event in events %}
{% if event.duration > 1000 %} <!-- Highlight slow events -->
<tr class="bg-red-100">
{% endif %}
<!-- ... rest of template ... -->
{% endfor %}
Disable Specific Collectors:
config/packages/dev.php:
web_profiler:
collectors:
# Disable the 'router' collector
router: false
How can I help you explore Laravel packages today?