effiana/web-profiler-extra-bundle
Installation:
composer require-dev elao/web-profiler-extra-bundle
Add to AppKernel.php (Symfony 2.x):
if (in_array($this->getEnvironment(), ['dev', 'test'])) {
$bundles[] = new \Elao\WebProfilerExtraBundle\WebProfilerExtraBundle();
}
Enable Collectors (in config_dev.yml):
web_profiler_extra:
routing: { enabled: true, display_in_wdt: true }
container: { enabled: true }
twig: { enabled: true }
assetic: { enabled: true }
First Use Case:
Access /_profiler/ in dev mode. New tabs appear for Routing, Container, Twig, and Assetic data.
Debugging Routes:
Service Inspection:
Twig Debugging:
Asset Management:
Conditional Activation:
Enable collectors only in dev/test environments to avoid performance overhead in production.
web_profiler_extra:
routing: { enabled: "%kernel.debug%" }
Custom Data:
Extend collectors by implementing \Elao\WebProfilerExtraBundle\Collector\CollectorInterface.
Example:
class CustomCollector implements CollectorInterface {
public function getName() { return 'custom'; }
public function collect() { return ['data' => 'value']; }
}
Register in services.yml:
services:
app.custom_collector:
class: AppBundle\Collector\CustomCollector
tags:
- { name: 'web_profiler_extra.collector' }
Exclude Sensitive Data: Filter out sensitive services from the Container tab:
web_profiler_extra:
container:
exclude_services: ['security.token_storage', 'session']
Performance Overhead:
config_dev.yml:
web_profiler_extra:
assetic: { enabled: false } # Disable if not needed
Outdated Data:
php bin/console cache:clear
Symfony 3/4/5 Compatibility:
symfony/web-profiler-bundle (built-in)stofl/web-profiler-bundle (extended)Assetic Deprecation:
Missing Collectors:
Ensure the bundle is registered in AppKernel.php and collectors are enabled in config_dev.yml.
Check for typos in YAML keys (e.g., routing vs route).
Twig Errors: If the Twig tab is empty, verify Twig extensions are properly tagged:
// In your Twig extension service definition
tags:
- { name: 'twig.extension' }
Container Data Truncation:
Large containers may truncate data. Use exclude_services to limit output:
web_profiler_extra:
container:
exclude_services: ['*doctrine*', '*monolog*']
Custom Collector: Create a collector to log custom metrics (e.g., API calls, database queries):
class ApiCollector implements CollectorInterface {
public function collect() {
return ['api_calls' => $this->apiService->getStats()];
}
}
Override Templates:
Customize the profiler UI by overriding templates in Resources/views/WebProfilerExtraBundle/.
Example:
app/Resources/WebProfilerExtraBundle/views/Collector/routing.html.twig
Event Listeners:
Hook into profiler events (e.g., web_profiler_extra.collect) to modify data dynamically:
services:
app.profiler_listener:
class: AppBundle\EventListener\ProfilerListener
tags:
- { name: 'kernel.event_listener', event: 'web_profiler_extra.collect', method: 'onCollect' }
How can I help you explore Laravel packages today?