benkle/doctrine-adoption-bundle
JOINED strategy), which is critical for hierarchical entity modeling (e.g., polymorphic behaviors, shared/inherited fields). This aligns well with Laravel’s Eloquent ORM limitations in handling complex inheritance natively.AppKernel.php), Laravel’s Doctrine Bridge (e.g., doctrine/orm) can integrate it via Symfony’s FrameworkBundle. The bundle’s focus on Doctrine’s inheritance (not Laravel-specific features) reduces friction.Document types with shared fields).type column).AppKernel.php, requiring:
symfony/framework-bundle) or a custom kernel to register the bundle.ServiceProvider) to bypass kernel registration.InheritanceType annotations, which may conflict with Laravel’s Eloquent conventions (e.g., extends traits vs. Doctrine’s @InheritanceType).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Doctrine vs. Eloquent | Breaks Laravel’s convention-over-configuration if Eloquent is primary. | Isolate Doctrine usage to specific modules (e.g., admin panels, legacy systems). |
| Performance | JOINED inheritance can bloat queries if not optimized (N+1 risks). |
Benchmark query plans; use Doctrine’s @Index or DQL optimizations. |
| Maintenance | Low-star, untested bundle with no dependents. | Fork and add Laravel-specific tests; monitor for updates. |
| Dependency Bloat | Adds Doctrine as a dependency, increasing bundle size and complexity. | Justify ROI via reduced custom query logic. |
| Annotation vs. Attributes | Uses PHP annotations (@Entity), which Laravel’s newer projects may replace with attributes. |
Check compatibility with doctrine/orm:convert-mapping for attribute migration. |
morphMap) or traits achieve similar goals with less overhead?JOINED strategy can be slower than Eloquent’s polymorphic approaches).extends, traits).JOINED/SINGLE_TABLE inheritance offers clear advantages (e.g., shared queries, discriminator columns).composer require doctrine/orm symfony/framework-bundle
config/packages/doctrine.yaml (Symfony-style) or use Laravel’s Doctrine Bridge.AppKernel.php (or extend Laravel’s kernel) to register the bundle.// app/Kernel.php (extend Symfony’s BaseKernel)
use Benkle\DoctrineAdoptionBundle\BenkleDoctrineAdoptionBundle;
class AppKernel extends BaseKernel {
public function registerBundles() {
return [
new BenkleDoctrineAdoptionBundle(),
// Other bundles...
];
}
}
AppServiceProvider:
use Benkle\DoctrineAdoptionBundle\DependencyInjection\BenkleDoctrineAdoptionExtension;
public function register() {
$this->mergeConfigFrom(__DIR__.'/../config/doctrine-adoption.php', 'doctrine_adoption');
$this->container->registerExtension(new BenkleDoctrineAdoptionExtension());
}
@InheritanceType("JOINED")./** @Entity @InheritanceType("JOINED") @DiscriminatorColumn(name="type") */
class Document { ... }
doctrine/orm:convert-mapping to migrate from annotations to attributes if needed.JOINED inheritance may need schema adjustments.Document types) and test the bundle’s services.AdoptionService for polymorphic queries).JOINED inheritance may require database migrations for discriminator columns or shared fields.doctrine/orm:schema-tool:update for migrations.doctrine/doctrine-bundle for Symfony-style CLI tools (if using kernel approach).SQL Logger.SELECT * FROM documents WHERE type IN (...)) are efficient.JOINED strategy can bloat tables with redundant columns. Consider SINGLE_TABLE for shallow hierarchies.| Scenario | Impact | Mitigation |
|---|---|---|
| Doctrine Configuration Errors | Broken entity mappings, runtime exceptions. | Use doctrine:schema:validate. |
| Query Performance Degradation |
How can I help you explore Laravel packages today?