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

stof/doctrine-extensions-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/Doctrine Alignment: The bundle is a native Symfony integration for gedmo/doctrine-extensions, a widely adopted library for Doctrine ORM enhancements (e.g., timestamps, slugs, trees, soft deletes, etc.). It fits seamlessly into Symfony’s bundle-based architecture, leveraging Doctrine’s event system without requiring custom listeners.
  • Modularity: Extensions are opt-in per entity, reducing bloat and allowing granular adoption (e.g., enable Timestampable for Post but not User).
  • ORM Agnosticism: While primarily for Doctrine ORM, the bundle could theoretically support Doctrine DBAL with minimal effort, though this isn’t documented.

Integration Feasibility

  • Low Friction: Installation via Composer (stof/doctrine-extensions-bundle) and configuration via config/packages/stof_doctrine_extensions.yaml is standardized and well-documented.
  • Dependency Graph:
    • Direct: Requires doctrine/doctrine-bundle (Symfony’s core) and doctrine/orm (v2.10+).
    • Transitive: Pulls in gedmo/doctrine-extensions (v3.7+), which may introduce minor version conflicts if other packages pin older Doctrine versions.
  • Database Schema Impact:
    • Extensions like Timestampable or SoftDeleteable modify schema (e.g., adding created_at, updated_at, deleted_at columns). Migrations must be planned to avoid downtime.
    • Tree behavior (e.g., NestedSet) requires indexes for performance, which may need manual tuning.

Technical Risk

Risk Area Severity Mitigation Strategy
Doctrine Version Lock Medium Pin gedmo/doctrine-extensions to a stable range (e.g., ^3.7) in composer.json.
Schema Migration High Use Doctrine Migrations (make:migration) or custom SQL for complex extensions (e.g., Tree).
Performance Overhead Low Benchmark queries with Tree/NestedSet; consider denormalization for read-heavy workloads.
Deprecation Risk Low Bundle is actively maintained (last release: 2026), but gedmo/doctrine-extensions is community-driven. Monitor GitHub issues.
Symfony 7+ Compatibility Medium Test with Symfony’s latest LTS; some extensions (e.g., Sortable) may need custom event subscribers.

Key Questions

  1. Which extensions are critical?
    • Prioritize (e.g., Timestampable for auditing, SoftDeleteable for retention policies).
    • Avoid over-engineering (e.g., Tree for flat data).
  2. How will schema changes be deployed?
    • Zero-downtime? Use blue-green deployments or read replicas during migrations.
  3. What’s the fallback for unsupported features?
    • Example: If Tree performance is poor, consider materialized paths or adjacency lists.
  4. How will testing cover extension behavior?
    • Write entity-specific tests for extensions (e.g., assertSoftDeleted()).
  5. Is there a need for custom extensions?
    • The bundle supports custom listeners, but these may require deeper Doctrine knowledge.

Integration Approach

Stack Fit

  • Symfony Ecosystem: Native fit for Symfony 5.4+ (tested up to Symfony 7.x). Works with:
    • Doctrine ORM (primary target).
    • API Platform (for GraphQL/REST APIs with extended entities).
    • Mercure/UX (real-time updates for Timestampable/SoftDeleteable events).
  • Non-Symfony PHP: Not recommended—the bundle is tightly coupled to Symfony’s dependency injection and bundle system. For vanilla PHP, use gedmo/doctrine-extensions directly.

Migration Path

  1. Assessment Phase:
    • Audit existing entities to identify candidate extensions (e.g., all entities need created_at/updated_at).
    • Check for conflicting annotations (e.g., custom @ORM\GeneratedValue vs. Timestampable).
  2. Dependency Setup:
    composer require stof/doctrine-extensions-bundle
    
    • Pin versions in composer.json:
      "require": {
        "stof/doctrine-extensions-bundle": "^1.7",
        "gedmo/doctrine-extensions": "^3.7"
      }
      
  3. Configuration:
    • Enable the bundle in config/bundles.php:
      Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
      
    • Configure in config/packages/stof_doctrine_extensions.yaml:
      stof_doctrine_extensions:
          orm:
              default:
                  timestampable: true
                  softdeleteable: true
                  # ... other extensions
      
  4. Entity Integration:
    • Add annotations to entities (e.g., use Gedmo\Mapping\Annotation as Gedmo):
      /**
       * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false)
       */
      class Post {}
      
    • Run migrations:
      php bin/console make:migration
      php bin/console doctrine:migrations:migrate
      
  5. Testing:
    • Validate with:
      php bin/console doctrine:schema:validate
      
    • Test extension behavior (e.g., SoftDeleteable queries):
      $repository->createQueryBuilder('p')
          ->where('p.deletedAt IS NULL')
          ->getQuery();
      

Compatibility

  • Doctrine ORM: Tested with v2.10+ (Symfony’s default). Avoid older versions (e.g., 2.5).
  • PHP Version: Requires PHP 8.1+ (due to Symfony 6+ dependencies).
  • Database: PostgreSQL/MySQL fully supported; SQLite may need tweaks for Tree extensions.
  • Legacy Code:
    • Repository methods: Update queries to account for new columns (e.g., WHERE deleted_at IS NULL).
    • Fixtures: Regenerate with doctrine/doctrine-fixtures-bundle to include new fields.

Sequencing

  1. Phase 1: Start with non-breaking extensions (Timestampable, Slugable).
  2. Phase 2: Introduce schema-changing extensions (SoftDeleteable, Tree) in a dedicated release.
  3. Phase 3: Optimize performance (e.g., add indexes for Tree).
  4. Phase 4: Customize (e.g., override SoftDeleteable behavior via events).

Operational Impact

Maintenance

  • Bundle Updates:
    • Monitor stof/doctrine-extensions-bundle for Symfony 8+ compatibility.
    • Watch gedmo/doctrine-extensions for breaking changes (e.g., annotation deprecations).
  • Dependency Management:
    • Lock Doctrine versions to avoid transitive conflicts.
    • Use composer why-not to debug dependency issues.
  • Documentation:
    • Maintain an internal runbook for:
      • Common extension configurations.
      • Migration rollback procedures.

Support

  • Debugging:
    • Enable Doctrine debug mode:
      doctrine:
          dbal:
              logging: true
      
    • Use stof_doctrine_extensions.event_listener logs for extension events.
  • Common Issues:
    • Timestampable: Timezone mismatches (configure default_timezone in config/packages/doctrine.yaml).
    • Tree: Performance degrades with deep hierarchies (consider MaterializedPath).
    • SoftDeleteable: Forgetting to filter queries (wrap in a query builder trait).
  • Vendor Support:
    • Community-driven: Issues may take time to resolve. Contribute fixes if critical.

Scaling

  • Performance:
    • Tree Extensions: Use MaterializedPath for read-heavy workloads (avoid NestedSet for >10k nodes).
    • SoftDeleteable: Add indexes on deleted_at for large tables.
    • Slugable: Cache slugs in a Redis-backed service to avoid duplicate checks.
  • Database Load:
    • Batch operations: Extensions like Timestampable add overhead to INSERT
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.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware