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

oro/doctrine-extensions

Adds extra Doctrine DQL functions and field types for MySQL and PostgreSQL (e.g., DATE/TIME, TIMESTAMPDIFF, CONVERT_TZ, DAY/WEEK/MONTH, MD5). Includes registration examples for common frameworks and guidance for extending platforms/functions.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Strong alignment with Laravel Doctrine ORM stack: The package extends Doctrine ORM functionality, which is natively supported in Laravel via doctrine/orm and doctrine/dbal. Since Laravel already integrates Doctrine, this package can be seamlessly incorporated without disrupting existing ORM workflows.
  • DQL-first approach: The package provides DQL functions (e.g., TIMESTAMPDIFF, GROUP_CONCAT, DATE_FORMAT) that map directly to SQL, enabling complex queries without raw SQL. This aligns with Laravel’s preference for query builder/ORM over raw SQL.
  • Field types (MoneyType, PercentType): Useful for financial applications but may require custom entity mapping in Laravel (via Doctrine annotations or YAML/XML mappings).

Integration Feasibility

  • High: Laravel’s Doctrine integration (via doctrine/doctrine-bundle or standalone) supports custom DQL functions. The package’s Symfony/Laminas configuration examples can be adapted for Laravel’s config/packages/doctrine.yaml.
  • Doctrine ORM 3.0 compatibility: Laravel typically uses Doctrine 2.x, but if the project is on Doctrine 3.x (e.g., Laravel 10+ with custom Doctrine setup), this package is a direct fit. For Doctrine 2.x, the 2.x branch of the package should be used.
  • Database support: Explicitly supports MySQL and PostgreSQL, which are the most common Laravel database backends. Other databases (SQLite, SQL Server) would require custom platform implementations.

Technical Risk

  • Breaking changes in Doctrine 3.0: If the project uses Doctrine 2.x, migrating to this package’s 3.x branch would require:
    • Upgrading Doctrine ORM to 3.x.
    • Adapting custom DQL functions (if any) to new API changes (e.g., FunctionFactory updates).
    • Testing all queries using the new functions.
  • Performance overhead: Some functions (e.g., GROUP_CONCAT) may introduce SQL-level aggregation, which could impact query performance on large datasets. Benchmarking is recommended.
  • Field type limitations: MoneyType and PercentType are not natively supported in Laravel’s Eloquent. Custom Doctrine mappings would be required, adding complexity.

Key Questions

  1. Doctrine ORM Version:
    • Is the project using Doctrine 2.x or 3.x? If 2.x, the package’s 2.x branch must be used.
  2. Database Compatibility:
    • Are we using MySQL/PostgreSQL? If not, custom platform implementations may be needed.
  3. Query Complexity:
    • Will this package replace existing raw SQL queries? If so, backward compatibility testing is critical.
  4. Field Type Adoption:
    • Are MoneyType/PercentType needed, or can native Laravel/Eloquent solutions (e.g., decimal columns) suffice?
  5. Performance Impact:
    • Have we benchmarked functions like GROUP_CONCAT on production-scale data?
  6. Custom Function Extensions:
    • Will we need to extend the package (e.g., add new DQL functions)? If so, the architecture for adding platforms/functions must be understood.

Integration Approach

Stack Fit

  • Laravel + Doctrine ORM: The package integrates natively with Doctrine, which Laravel supports via:
    • Standalone: doctrine/orm + doctrine/dbal.
    • Symfony Bundle: doctrine/doctrine-bundle (common in Laravel with Symfony components).
  • Query Builder Compatibility:
    • The package’s DQL functions can be used in Doctrine QueryBuilder or native Laravel Query Builder (via DB::raw() or custom expressions).
    • Example:
      // Using QueryBuilder with custom DQL function
      $qb = $entityManager->createQueryBuilder();
      $qb->select('DATE(u.createdAt) as created_date')
         ->from(User::class, 'u');
      
  • Eloquent Limitations:
    • Eloquent does not support custom DQL functions out of the box. Workarounds:
      • Use raw SQL in queries (DB::select()).
      • Extend Eloquent’s query grammar (advanced).
      • Stick to Doctrine QueryBuilder for complex queries.

Migration Path

  1. Assess Current Usage:
    • Audit existing queries using raw SQL or Doctrine functions. Identify candidates for replacement.
  2. Installation:
    • Add to composer.json:
      "oro/doctrine-extensions": "^3.0"
      
    • For Doctrine 2.x, use ^2.0.
  3. Configuration:
    • Register functions in config/packages/doctrine.yaml (Symfony-style):
      doctrine:
          orm:
              dql:
                  datetime_functions:
                      date: Oro\ORM\Query\AST\Functions\SimpleFunction
                      timestampdiff: Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff
                  string_functions:
                      group_concat: Oro\ORM\Query\AST\Functions\String\GroupConcat
      
    • For standalone Doctrine, configure in PHP:
      $config = new \Doctrine\ORM\Configuration();
      $config->addCustomDatetimeFunction('date', 'Oro\ORM\Query\AST\Functions\SimpleFunction');
      
  4. Testing:
    • Validate all queries using new functions. Pay special attention to:
      • SQL generation (e.g., GROUP_CONCAT syntax differs between MySQL/PostgreSQL).
      • Performance (compare with raw SQL).
  5. Deprecate Raw SQL:
    • Gradually replace raw SQL with DQL functions where applicable.

Compatibility

  • Doctrine ORM 3.0: Required for ^3.0 of the package. If using Doctrine 2.x, use ^2.0.
  • PHP 8.1+: Required for ^3.0. If using PHP <8.1, use ^2.0.
  • Database Dialects:
    • MySQL/PostgreSQL: Fully supported.
    • SQLite/SQL Server: Not natively supported; custom platform implementations needed.
  • Laravel Eloquent: Limited support. Prefer Doctrine QueryBuilder for full functionality.

Sequencing

  1. Phase 1: Setup and Configuration
    • Install package, configure DQL functions, and test basic queries.
  2. Phase 2: Query Migration
    • Replace raw SQL with DQL functions in critical paths (e.g., reports, analytics).
  3. Phase 3: Field Type Adoption (Optional)
    • If using MoneyType/PercentType, update entity mappings and test.
  4. Phase 4: Performance Optimization
    • Benchmark queries and optimize indexes/joins as needed.
  5. Phase 5: Rollback Plan
    • Document fallback to raw SQL for unsupported cases.

Operational Impact

Maintenance

  • Dependency Updates:
    • The package is actively maintained (last release: 2025-11-06). Monitor for Doctrine ORM 3.x updates and PHP version requirements.
  • Custom Extensions:
    • If extending the package (e.g., adding new functions), maintain custom code in sync with upstream changes.
  • Doctrine Configuration:
    • Changes to DQL functions require configuration updates. Use version control for doctrine.yaml.

Support

  • Troubleshooting:
    • Issues may arise from:
      • SQL syntax errors (e.g., GROUP_CONCAT differences between databases).
      • Doctrine version mismatches (e.g., using 3.x functions with 2.x ORM).
    • Debugging tools:
      • Enable Doctrine SQL logging (doctrine.event_listeners.sql_logger).
      • Use dd() on generated SQL queries.
  • Community Resources:
    • GitHub issues, OroCRM documentation (since this package originates from OroCRM).
    • Limited Laravel-specific support; may need to engage Doctrine/Laravel communities.

Scaling

  • Performance Considerations:
    • Complex functions (e.g., TIMESTAMPDIFF, GROUP_CONCAT) may introduce SQL-level overhead. Test with production-like datasets.
    • Indexing: Ensure proper indexes exist for columns used in DQL functions (e.g., DATE() extractions).
  • Database Load:
    • Functions like GROUP_CONCAT can be resource-intensive on large result sets. Consider:
      • Pagination (LIMIT/OFFSET).
      • Application-side aggregation for very large datasets.
  • Horizontal Scaling:
    • No direct impact on Laravel’s horizontal scaling (e.g., queue workers, caching). However, query performance may affect read-heavy services.

Failure Modes

Risk Impact Mitigation
Doctrine ORM version mismatch Broken queries, runtime
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.
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
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata