First Steps
Learn how to use Doctrine Doctor effectively in your Symfony project.
Understanding the Profiler Panel
The Doctrine Doctor panel appears in the Symfony Web Profiler toolbar after each request.
Panel Overview
The panel displays:
- Issue count by severity (
critical,warning,info) - Category breakdown (Performance, Security, Integrity, Configuration)
- Total queries analyzed
- Analysis time (overhead)
Reading Issue Reports
Each issue contains:
1. Title and Severity
π΄ Critical: N+1 Query Detected
2. Description
Detailed explanation of the problem and its impact.
3. Affected Queries
The specific SQL queries involved:
SELECT * FROM user WHERE id = ?
-- Executed 100 times
4. Backtrace (if enabled)
Code location where the query originated:
src/Controller/UserController.php:42
templates/user/index.html.twig:15
5. Suggestion
Actionable solution with code example:
$users = $repository
->createQueryBuilder('u')
->leftJoin('u.profile', 'p')
->addSelect('p')
->getQuery()
->getResult();
Common Workflow
1. Develop as Normal
Write your Symfony code without worrying about Doctrine Doctor.
2. Check the Profiler
After loading a page, click the Doctrine Doctor panel in the profiler.
3. Review Issues
Focus on Critical issues first, then Warning issues.
4. Apply Suggestions
Use the provided code examples to fix issues.
5. Verify Fix
Refresh the page and confirm the issue is resolved.
Configuring Analyzers
Customize analyzer behavior in config/packages/dev/doctrine_doctor.yaml:
Example: Stricter N+1 Detection
doctrine_doctor:
analyzers:
n_plus_one:
threshold: 2 # Detect even minor N+1 issues
Example: Adjust Slow Query Threshold
doctrine_doctor:
analyzers:
slow_query:
threshold: 50 # Flag queries over 50ms
See full configuration reference β
Best Practices
During Development
- Keep Doctrine Doctor enabled in the dev environment
- Enable backtraces for precise issue location
- Review issues regularly before committing code
- Fix Critical/Warning issues immediately
Before Deployment
- Run tests to ensure fixes donβt break functionality
- Review staging environment with production-like data
- Ensure Doctrine Doctor is disabled in production
Team Collaboration
- Share configuration via version control
- Document common patterns your team encounters
- Set team standards for acceptable thresholds
- Review issues in code reviews
Understanding Severity Levels
π΄ Critical
- Security vulnerabilities (SQL injection)
- Data loss risk (cascade misconfiguration)
- Major performance issues (100+ N+1 queries)
Action: Fix immediately before committing
π Warning
- Significant performance degradation (missing indexes)
- Architectural violations
- Major inefficiencies
Action: Fix before merging to main branch
π΅ Info
- Non-blocking improvements
- Minor quality/performance suggestions
- Refactoring opportunities
Action: Plan and address progressively