bengor-user/doctrine-orm-bridge
Doctrine ORM bridge for BenGorUser: adapters and persistence integration to make the User model compatible with Doctrine ORM. Install via Composer and run the fully tested PHPSpec suite; documentation lives in the main User library docs.
User entity and Doctrine ORM, implying it may not fully align with modern Laravel conventions (e.g., Eloquent ORM dominance). If the project already uses Doctrine ORM (uncommon in Laravel), this could be a viable fit. Otherwise, it introduces unnecessary complexity.Auth facade and User model are hardcoded to Eloquent. Replacing this with Doctrine would require rewriting middleware, guards, and authentication logic, increasing technical debt.User entity structure. If the project’s users table deviates from Doctrine’s expectations (e.g., custom column names, relationships), additional mapping logic would be required.Why Doctrine ORM?
Project Constraints
Long-Term Viability
Testing and Validation
Auth service provider with a custom one.User model and its relationships.Authenticate, Authorize) to work with Doctrine entities.Assessment Phase
User-related code (controllers, policies, jobs, etc.) to identify dependencies on Eloquent-specific features.Incremental Integration
app/Doctrine). Use Laravel’s service container to register Doctrine’s EntityManager as a singleton.DoctrineUserRepository) to translate between the User entity and Doctrine’s expectations. This acts as a buffer until full migration.User model usages in critical paths (e.g., authentication endpoints) while keeping Eloquent for non-critical paths.Authentication Override
AuthManager to support Doctrine guards. Example:
// config/auth.php
'guards' => [
'web' => [
'driver' => 'doctrine',
'provider' => 'doctrine_users',
],
],
DoctrineGuard that uses the EntityManager instead of Eloquent.Database Schema Alignment
users table schema matches Doctrine’s expectations (e.g., @ORM\Table, @ORM\Column annotations). Use Doctrine’s schema tool to validate:
vendor/bin/doctrine schema:validate
| Phase | Tasks | Risks |
|---|---|---|
| Proof of Concept | Set up Doctrine ORM in a sandbox project; test basic User CRUD. |
High (unproven in Laravel). |
| Wrapper Layer | Create a repository pattern to abstract Doctrine queries. | Medium (requires careful interface design). |
| Authentication | Replace Laravel’s Auth guard with a Doctrine-compatible version. |
High (authentication is core functionality). |
| Feature Migration | Migrate one feature (e.g., user registration) at a time. | Medium (regression risk in auth flows). |
| Full Cutover | Remove Eloquent User model entirely; update all dependencies. |
Critical (requires full QA). |
doctrine/annotations, doctrine/cache), increasing Composer complexity.illuminate/database or laravel/framework packages.EntityManager is properly configured for stateless environments (e.g., connection: null in queues).| Scenario | Impact | Mitigation Strategy |
|---|---|---|
| Package Abandonment | No updates for security vulnerabilities or PHP version support. | Fork the repository; maintain a private branch. |
| Doctrine-Laravel Conflict | Service provider collisions or autoloading errors. | Isolate Doctrine in a separate namespace; use explicit bindings in the container. |
| Authentication Breakage | Failed logins, CSRF token issues, or session mismatches. | Implement a fallback to Eloquent during migration; thorough auth testing. |
| Schema Mismatch | Doctrine fails to map |
How can I help you explore Laravel packages today?