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 Bridge Laravel Package

php-debugbar/doctrine-bridge

Doctrine Bridge for PHP Debug Bar adds collectors to profile Doctrine ORM/DBAL activity in the PHP Debug Bar. Install via Composer, run the included demo with a local DB, and execute PHPUnit/Panther tests for verification.

View on GitHub
Deep Wiki
Context7

Getting Started

Install via Composer: composer require --dev php-debugbar/doctrine-bridge. Then ensure php-debugbar/php-debugbar is already installed and configured (e.g., via Laravel’s built-in Debugbar support or manually for Symfony/standalone). In your Doctrine setup, attach the bridge’s QueryCollector to the Configuration object using addFilter() — typically in your config/packages/doctrine.php (Laravel) or service definition (Symfony). The first HTTP request will automatically populate the “Queries” panel in Debug Bar, showing recent DBAL/ORM operations with timing and SQL.

Implementation Patterns

  • Automatic Integration: No manual instrumentation needed — the bridge hooks into Doctrine’s Connection and EntityManager lifecycle. Simply instantiate your EntityManager after loading the bridge; all queries via it will be captured.
  • Per-Request Profiling: Ideal for development, injected via environment-specific service providers or kernel bootstrapping (e.g., only enable when APP_DEBUG=true). Avoid production部署.
  • Custom Collector Registration: For advanced usage, register additional collectors (e.g., for cache or caching drivers) by extending the bridge’s Collector classes and adding them to the DebugBar instance manually.
  • Integration with Laravel: If using Laravel, laravel-doctrine often handles this automatically, but for vanilla Doctrine setup in Laravel, add a ServiceProvider that binds the bridge collector after Doctrine’s setup.

Gotchas and Tips

  • Cache Drivers Not Captured: Only DBAL queries are collected — Doctrine second-level cache queries or metadata/cache operations won’t appear unless explicitly instrumented.
  • Lazy Connections Delay Hooks: If using lazy connections (conn1 via connection vs default), verify the correct connection is passed to the bridge; misconfigured lazy setups can cause silent query loss.
  • Memory Usage Warning: Long-running CLI scripts may accumulate collected data — always disable in production or reset collectors manually after batch jobs.
  • SQL Logging Overhead: The collector applies to all Doctrine connections unless selectively disabled — use setCollectQuery on individual connections to reduce noise in complex multi-DB setups.
  • Extensibility: To add custom metrics (e.g., entity lifecycle timings), subclass DoctrineCollector and override getMetadata() to inject synthetic panels — useful for detecting hydration bottlenecks in complex result sets.
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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport