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

larapack/doctrine-support

Laravel package that enhances Doctrine support in Laravel, including support for enum types. Install via Composer and (for Laravel 5.4 and below) register the DoctrineSupportServiceProvider. Use v0.1.3 for Laravel versions older than 5.4.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Doctrine ORM Integration: The package bridges Laravel’s Eloquent ORM with Doctrine ORM, enabling hybrid ORM usage. This remains valuable for teams using Doctrine in other parts of their stack (e.g., Symfony microservices) or needing advanced Doctrine features (e.g., DQL, complex queries). The hybrid approach retains Laravel’s Eloquent patterns while extending functionality.
  • Enum Support: Explicit enum support aligns with modern PHP (8.1+) and Doctrine’s capabilities, improving type safety and schema design. This remains a key differentiator from native Eloquent.
  • Laravel Compatibility: The package targets Eloquent, avoiding full Doctrine migration. However, support for Laravel 6.0 (released 2019) introduces critical risks:
    • Laravel 10.x/11.x: The package is 5+ major versions behind, with no mention of compatibility with modern Laravel (e.g., model events, query builder changes, or PHP 8.2+ features like read-only properties).
    • Deprecated Features: Laravel 6.0 lacks support for PHP 8.x attributes (replacing Doctrine annotations), which are now standard in Doctrine 2.10+.
    • Breaking Changes: Laravel 7+ introduced changes to model events, query builder, and service providers that may conflict with the package’s internals.
  • Potential Overhead: Doctrine’s dependencies (doctrine/orm, doctrine/dbal) remain heavy, increasing bundle size and complexity. This is exacerbated by the lack of modern Laravel support.

Integration Feasibility

  • Hybrid ORM Viability: The dual-ORM approach introduces complexity in query logic, caching, and transactions. Critical risks:
    • Schema Conflicts: Doctrine’s strict typing and annotations may clash with Laravel’s migrations or seeders, especially in shared tables.
    • Testing Overhead: Mocking Doctrine’s EntityManager or testing DQL queries in Laravel’s test suite is non-trivial and may require custom test utilities.
    • Caching Conflicts: Doctrine’s second-level cache may interact unpredictably with Laravel’s cache drivers (e.g., Redis, file), requiring manual configuration.
  • Database Schema Alignment: Doctrine’s schema requirements (e.g., annotations, strict typing) may conflict with Laravel’s dynamic schema changes, necessitating careful synchronization.

Technical Risk

  • Deprecation Risk:
    • Last Release in 2019: The package is abandoned, with no updates for 5+ years. Key risks:
      • No PHP 8.2+ Support: PHP 8.2 introduced breaking changes (e.g., array type deprecation, new attributes), which may break Doctrine’s internals.
      • No Laravel 10.x/11.x Support: Modern Laravel features (e.g., model macros, query builder improvements) are unsupported.
      • Doctrine 2.10+ Incompatibility: Newer Doctrine versions use PHP attributes (e.g., [ORM\Column]) instead of annotations, which the package may not support.
    • Security Vulnerabilities: Unpatched dependencies (e.g., doctrine/orm, doctrine/dbal) may introduce CVEs.
  • Maintenance Burden: Without active maintenance, the package will accumulate technical debt, requiring custom patches or forks.
  • Performance Trade-offs: Doctrine’s ORM layer adds abstraction, potentially impacting query performance. No benchmarks exist for Laravel 10.x/PHP 8.2+.
  • Community Support: With 175 stars and no recent activity, troubleshooting will rely on outdated docs or reverse-engineering the codebase.

Key Questions

  1. Compatibility:
    • Does v0.1.9 work with Laravel 10.x/11.x or PHP 8.2+? If not, what are the blocking issues (e.g., model events, attributes, or query builder changes)?
    • Are annotations still required, or does it support PHP attributes (e.g., [ORM\Column])? If not, how are Doctrine’s modern mapping strategies handled?
  2. Functional Scope:
    • What Doctrine features are unsupported? (e.g., inheritance mapping, custom repositories, events, or DQL limitations).
    • How are conflicts resolved between Eloquent and Doctrine configurations? (e.g., connection names, default repositories, or event listeners).
  3. Performance:
    • Are there benchmarks for Laravel 10.x/PHP 8.2+? How does Doctrine’s overhead compare to Eloquent for the same queries?
    • What is the memory/CPU impact of the hybrid ORM setup? (e.g., dual entity managers, caching layers).
  4. Migration Path:
    • Can existing Eloquent models be incrementally converted to Doctrine entities without breaking changes? What are the risks of shared models?
    • How are migrations handled for shared tables? (e.g., Doctrine’s schema-tool vs. Laravel’s migrations).
  5. Long-Term Viability:
    • Is this package a "legacy hold" for Laravel 6.x projects, or are there plans for modernization? If not, what alternatives exist? (e.g., spatie/laravel-doctrine-orm, custom Eloquent macros, or full Doctrine migration).
    • What is the upgrade path to a maintained package? (e.g., forking, switching to Doctrine’s native Laravel integration, or using a different hybrid ORM solution).
  6. Testing:
    • How does the package handle testing in modern Laravel? (e.g., mocking EntityManager, testing DQL queries, or asserting hybrid ORM behaviors).
    • Are there built-in tools for validating Doctrine-specific configurations? (e.g., schema validation, annotation parsing).

Integration Approach

Stack Fit

  • Ideal Use Cases:
    • Legacy Laravel 6.x Projects: Only viable for teams stuck on Laravel 6.x due to the package’s lack of modern support.
    • Hybrid Applications: Projects using Eloquent for most logic but needing Doctrine for specific legacy features (e.g., DQL queries, Symfony integration).
    • Enum/Type Safety: Projects requiring strict enum handling where Eloquent’s native support is insufficient (though modern Laravel has improved this).
  • Anti-Patterns:
    • Modern Laravel Projects (7.x+): Avoid due to unsupported features (e.g., PHP 8.2+, attributes, model events).
    • Performance-Critical Paths: Doctrine’s overhead is prohibitive for high-throughput APIs or real-time systems.
    • Annotation-Heavy Codebases: Projects relying on Doctrine annotations may face friction with PHP attributes or require dual maintenance.
    • Greenfield Projects: New Laravel projects should not adopt this package to prevent technical debt.

Migration Path

  1. Assessment Phase:
    • Audit Compatibility: Verify if the package works with the target Laravel/PHP version. If not, assess the effort to fork or patch it.
    • Identify Use Cases: Determine which Doctrine features are critical (e.g., DQL, enums) vs. nice-to-have.
    • Benchmark Queries: Compare Eloquent vs. Doctrine performance for critical paths.
  2. Pilot Integration (if feasible):
    • Isolate Scope: Test in a non-critical module (e.g., admin panel) with feature flags to toggle between Eloquent/Doctrine.
    • Dependency Setup: Install Doctrine packages and configure the EntityManager in Laravel’s service container.
    • Model Layer: Extend Eloquent models with Doctrine traits or create hybrid entities.
  3. Incremental Adoption (if justified):
    • Convert Models: Migrate models incrementally, ensuring:
      • Doctrine entities extend Laravel’s Model or use shared traits.
      • Migrations support both ORMs (e.g., using Schema::table() for shared tables).
      • Caching strategies account for both ORMs (e.g., separate cache prefixes).
    • Query Layer: Replace Eloquent queries with DQL where needed, using repositories to abstract differences.
  4. Dependency Management:
    • Pin Doctrine to a stable version (e.g., ^2.7) to avoid breaking changes.
    • Add to composer.json:
      composer require doctrine/orm doctrine/dbal doctrine/annotations
      
    • Configure Laravel’s service provider to bootstrap Doctrine’s EntityManager without conflicting with Eloquent.

Compatibility

  • Laravel Versions:
    • Laravel 6.x Only: The package is not compatible with Laravel 7.x+ due to breaking changes in model events, query builder, and service providers.
    • Workarounds: If using Laravel 7+, consider:
      • Forking the package and backporting changes.
      • Using a different hybrid ORM solution (e.g., spatie/laravel-doctrine-orm).
      • Migrating to full Doctrine or custom Eloquent macros.
  • Doctrine Versions:
    • Avoid 2.10+: The package likely doesn’t support PHP attributes, which are required for modern Doctrine.
    • Pin to 2.7.x: Use a stable, annotation-based version to minimize conflicts.
  • Database Drivers:
    • Verify support for the
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor