Installation:
composer require aureja/web-profiler-bundle "dev-master"
Register the Bundle:
Add the bundle to AppKernel.php under dev/test environments:
$bundles[] = new Aureja\Bundle\WebProfilerBundle\AurejaWebProfilerBundle();
Enable Profiling:
php bin/console cache:clear.http://localhost:8000/_profiler). The profiler toolbar should appear.First Use Case:
/_profiler to view ORM queries and detect duplicates.Query Analysis:
Duplicate Detection:
Integration with Symfony Profiler:
Development Workflow:
Custom Data Collection:
Gotchas for details).Doctrine Event Listeners:
query or resultSet events to log custom metrics:
$eventManager->addEventListener(
Doctrine\ORM\Events::POST_FLUSH,
function ($event) {
// Log N+1 queries or other custom logic.
}
);
Toolbar Configuration:
# config/packages/dev/aureja_web_profiler.yaml
aureja_web_profiler:
toolbar: true
position: bottom # 'top' or 'bottom'
Excluding Queries:
$profiler->setQueryFilter(function ($sql) {
return !str_contains($sql, 'migration_');
});
Performance Overhead:
if ($this->getEnvironment() !== 'dev') {
return;
}
$bundles[] = new AurejaWebProfilerBundle();
--env=test for CI to avoid false positives.Duplicate Query False Positives:
WHERE id = ?) may be flagged as duplicates.QueryCollector (extend Aureja\Bundle\WebProfilerBundle\DataCollector\QueryCollector).Template Overrides:
templates/bundles/aurejawebprofiler/ to customize output.Doctrine Version Mismatch:
~2.5. For newer versions (e.g., 3.x), patch the QueryListener or fork the bundle.Missing Data in Profiler:
dev/test environments.config/packages/doctrine.yaml).Log Query Events:
# config/packages/dev/doctrine.yaml
doctrine:
dbal:
logging: true
profiling: true
Check Bundle Initialization:
AurejaWebProfilerBundle::build() method to ensure collectors are registered:
dump($this->get('profiler')->getDataCollectors());
Query Comparison Logic:
QueryCollector class to understand how duplicates are detected. Override the isDuplicate() method if needed:
class CustomQueryCollector extends QueryCollector {
public function isDuplicate(Query $query, array $queries) {
// Custom logic here.
}
}
Custom Data Collectors:
DataCollectorInterface and registering them in the bundle’s Resources/config/services.yaml:
services:
app.custom_profiler:
class: App\Profiler\CustomCollector
tags: ['data_collector']
Query Annotations:
use Aureja\Bundle\WebProfilerBundle\Annotation\ProfileQuery;
/**
* @ProfileQuery("custom_label")
*/
public function index() { ... }
Export Profiler Data:
$profiler->exportData('/path/to/output.json');
Visual Indicators:
{# templates/bundles/aurejawebprofiler/toolbar.html.twig #}
{% if hasDuplicateQueries %}
<span class="badge badge-danger">Duplicates: {{ duplicateCount }}</span>
{% endif %}
How can I help you explore Laravel packages today?