Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Doctrine Doctor Laravel Package

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.

View on GitHub
Deep Wiki
Context7

layout: default title: Quick Start parent: Getting Started nav_order: 1

Quick Start

Get Doctrine Doctor running in your Symfony project in under 30 seconds.


Installation

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!


Verify Installation

  1. Refresh any page in your Symfony application (in dev environment)
  2. Open the Symfony Web Profiler (bottom toolbar)
  3. Look for the "Doctrine Doctor" panel

First Analysis

Doctrine Doctor automatically analyzes all database queries executed during your request.

Example: Detect N+1 Query

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!


Enable Backtraces (Recommended)

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.


Next Steps

  • [Configure analyzers]({{ site.baseurl }}/user-guide/configuration) to match your needs
  • [Explore all 90+ analyzers]({{ site.baseurl }}/user-guide/analyzers) available
  • [Learn about the architecture]({{ site.baseurl }}/advanced/architecture)
  • [See more examples]({{ site.baseurl }}/examples/n-plus-one)
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver