ahmed-bhs/doctrine-doctor
Doctrine Doctor is a runtime analysis tool for Doctrine ORM integrated into the Symfony Web Profiler. It detects real-world issues like N+1 queries, slow queries, missing indexes, hydration overhead, and injection risks, with actionable backtraces and suggestions.
Get Doctrine Doctor running in your Symfony project in under 30 seconds.
Install via Composer:
composer require --dev ahmed-bhs/doctrine-doctor
{: .note-title }
Auto-Configuration
Doctrine Doctor is automatically configured via Symfony Flex. No manual setup required!
dev environment)Doctrine Doctor automatically analyzes all database queries executed during your request.
Create a simple controller:
<?php
namespace App\Controller;
use App\Repository\UserRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
class UserController extends AbstractController
{
#[Route('/users', name: 'app_users')]
public function index(UserRepository $userRepository): Response
{
$users = $userRepository->findAll();
return $this->render('user/index.html.twig', [
'users' => $users,
]);
}
}
And a Twig template:
{% raw %}{# templates/user/index.html.twig #}
{% for user in users %}
<p>{{ user.name }} - {{ user.profile.bio }}</p>
{% endfor %}{% endraw %}
Result: Doctrine Doctor will detect the N+1 query issue and suggest using eager loading!
To see exactly WHERE in your code issues originate, enable query backtraces:
# config/packages/dev/doctrine.yaml
doctrine:
dbal:
profiling_collect_backtrace: true
{: .highlight }
Performance Impact: Backtrace collection has minimal overhead (~2-5%) and is recommended for development.
How can I help you explore Laravel packages today?