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

Orm Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Doctrine Object Relational Mapper (ORM)

Frequently asked questions about Orm
Can I use Doctrine ORM alongside Laravel Eloquent in the same project?
Yes, but you’ll need an adapter like `laravel-doctrine` to bridge the two. Doctrine ORM and Eloquent can coexist, though Eloquent models must be refactored to Doctrine entities for full integration. This hybrid approach lets you use Doctrine for complex queries while keeping Eloquent for simpler operations.
What Laravel versions support Doctrine ORM 4.x?
Doctrine ORM 4.x requires PHP 8.1+ and is best suited for Laravel 10+. Earlier Laravel versions (e.g., 9.x) may need Doctrine 3.x, but ensure compatibility with your PHP version. Always check the [Doctrine docs](https://www.doctrine-project.org/projects/doctrine-orm/en/stable/index.html) for version-specific notes.
How do I migrate from Eloquent to Doctrine ORM in Laravel?
Start by converting Eloquent models to Doctrine entities using annotations or XML/YAML mappings. Replace Eloquent’s `Model` class with Doctrine’s `Entity` base class and update queries to use DQL or the QueryBuilder. Tools like `doctrine/orm`’s schema tool can help generate migrations for existing databases.
Is Doctrine ORM faster than Eloquent for large datasets?
Yes, Doctrine ORM often outperforms Eloquent in complex scenarios due to its advanced caching (e.g., second-level cache), batch processing, and lazy loading strategies. For simple CRUD, the difference may be negligible, but Doctrine excels in high-performance apps with intricate queries or multi-tenancy.
Can I use Doctrine Query Language (DQL) in Laravel without replacing Eloquent?
Not directly—DQL is tied to Doctrine’s entity system. However, you can use Doctrine’s QueryBuilder alongside Eloquent by leveraging adapters or writing raw SQL queries via DBAL. For full DQL support, you’d need to adopt Doctrine entities entirely or use a package like `doctrine/orm` with a custom query layer.
How does Doctrine handle Laravel’s migrations (e.g., `php artisan migrate`)?
Doctrine ORM replaces Laravel migrations with its own migration system (`doctrine/doctrine-migrations-bundle`). You’ll need to generate Doctrine migrations for your entities and run them via `doctrine:migrations:migrate`. This works well for greenfield projects but requires refactoring existing Laravel migrations.
Are there performance trade-offs when using Doctrine ORM in production?
Doctrine’s proxy objects and hydration strategies can introduce slight overhead, but this is mitigated by caching and lazy loading. For production, optimize by enabling second-level caching (e.g., Redis) and tuning hydration modes. Benchmark your specific workloads, as Doctrine’s performance scales better with complex data than Eloquent.
What alternatives exist to Doctrine ORM for Laravel if I need advanced ORM features?
For Laravel, alternatives include sticking with Eloquent (for simplicity) or exploring `Cycle ORM` (a lightweight, annotation-free ORM) or `RedBeanPHP` (for rapid development). However, none match Doctrine’s maturity, DQL, or enterprise-grade features. If you need SQL-like power without full Doctrine, consider `spatie/laravel-query-builder`.
How do I configure Doctrine ORM in Laravel’s `config/database.php`?
Doctrine ORM doesn’t directly use Laravel’s `database.php`—it relies on its own configuration (e.g., `config/doctrine.yaml` in Symfony-style bundles). For Laravel, use packages like `laravel-doctrine` to auto-configure Doctrine with your existing database connections. Ensure your `AppServiceProvider` binds Doctrine’s entity manager to Laravel’s IoC container.
Does Doctrine ORM support Laravel’s Scout for full-text search?
No, Doctrine ORM doesn’t natively integrate with Laravel Scout. Scout relies on Eloquent models, so you’d need to either keep Eloquent for Scout or build a custom search layer using Doctrine’s QueryBuilder or DQL. For full-text search, consider using Doctrine’s native database functions or a dedicated search engine like Algolia.
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony