doctrine/orm
Doctrine ORM is a PHP 8.1+ object-relational mapper built on Doctrine DBAL, providing transparent persistence for PHP objects. Use mappings, repositories, and Unit of Work, plus DQL for powerful, object-oriented querying as an alternative to SQL.
doctrine/dbal and doctrine/annotations. It aligns well with Laravel’s dependency injection (DI) container and service provider architecture, enabling seamless adoption.doctrine/dbal (Database Abstraction Layer) for cross-database compatibility.doctrine/annotations or doctrine/orm for entity mapping (requires configuration in config/app.php and service providers).illuminate/database bridges (e.g., laravel-doctrine/orm) for Eloquent interoperability.doctrine/migrations) enable database schema versioning alongside Laravel’s migrations.pdo_mysql, pdo_pgsql).Gedmo) for soft deletes, timestamps, or tree structures if needed.prePersist) may conflict with Laravel’s model events. Use middleware or event dispatchers to reconcile.EntityManager and Connection as Laravel services in config/app.php and a custom service provider.EntityManagerInterface into controllers/services via Laravel’s container.config/database.php to include Doctrine-specific settings (e.g., caching, event listeners).doctrine/dbal for raw SQL queries or database-agnostic operations alongside Eloquent.doctrine/orm’s SchemaTool for schema validation or doctrine/migrations for versioned migrations.UserRepository) for business logic encapsulation.postLoad) to Laravel’s model events or custom event dispatchers.Phase 1: Proof of Concept (PoC)
EntityManager alongside Eloquent.Phase 2: Hybrid Integration
doctrine/orm:convert-mapping to auto-generate annotations from existing database schemas.robmorgan/phinx for hybrid migration management.Phase 3: Full Adoption (Optional)
spatie/laravel-permission may need configuration updates).composer.json:
"require": {
"doctrine/orm": "^4.0",
"doctrine/dbal": "^4.0",
"doctrine/annotations": "^2.0",
"doctrine/cache": "^2.2"
}
config/app.php and a custom service provider:
$this->app->bind(\Doctrine\ORM\EntityManagerInterface::class, function ($app) {
return EntityManager::create($app['config']['doctrine'], $app['doctrine.connection']);
});
How can I help you explore Laravel packages today?