byteincoffee/doctrine-extensions
Laravel package integrating Doctrine Extensions with Eloquent models, adding behaviors like timestampable, sluggable, soft delete, and more. Provides easy configuration, listeners/subscribers, and seamless use of Doctrine-style extensions in Laravel apps.
where, orderBy), this package may introduce duplication (Doctrine vs. Eloquent syntax). Assess whether the extensions (e.g., soft deletes, tree behavior, sluggable) justify the switch.doctrine/orm and doctrine/doctrine-bundle (Symfony dependency).EntityManager alongside Eloquent (potential namespace collisions if both ORMs manage the same models).fillable arrays.$model->save() vs. EntityManager::persist()).prePersist) must replace or coexist with Eloquent’s observers/events.| Risk Area | Mitigation Strategy |
|---|---|
| Namespace Collisions | Use Doctrine’s Proxy\__CG__* classes or alias namespaces in composer.json. |
| Performance Overhead | Profile with doctrine/orm:query logging and optimize N+1 queries. |
| Breaking Changes | Test with a forked package or patch locally until stability is confirmed. |
| Dependency Bloat | Audit doctrine/orm dependencies (e.g., symfony/*) for conflicts with Laravel. |
| Learning Curve | Train team on Doctrine’s DQL and lifecycle callbacks vs. Eloquent’s methods. |
spatie/laravel-activitylog) sufficient?doctrine/orm:validate-schema)?gedmo/doctrine-extensions)?doctrine/doctrine-migrations-bundle) alongside Laravel migrations?DoctrineRepository pattern) for gradual adoption.doctrine/orm (e.g., v2.10+ for PHP 8.1).composer.json:
composer require doctrine/orm doctrine/doctrine-bundle byteincoffee/doctrine-extensions
config/doctrine.php (Symfony-style) alongside Laravel’s config/database.php.// app/Repositories/ModelRepository.php
class UserRepository {
public function __construct(private EntityManager $em, private User $eloquentModel) {}
public function find(int $id): UserEntity { return $this->em->find(UserEntity::class, $id); }
}
Model classes with Doctrine Entity classes.ObjectManager.HasFactory traits).SoftDeletes trait with Doctrine’s SoftDeleteable listener.TreeType for nested sets (vs. Eloquent’s kalnoy/nestedset).spatie/laravel-sluggable with Slugable extension.@ORM\GeneratedValue vs. Eloquent’s $timestamps.ManyToMany requires JoinTable annotations vs. Eloquent’s belongsToMany.Model::query()->where() with DQL or Criteria.| Step | Dependencies |
|---|---|
1. Add Doctrine to composer.json |
None |
2. Configure Doctrine in config/ |
doctrine/doctrine-bundle installed |
| 3. Migrate 1–2 models to Doctrine | Doctrine EntityManager bootstrapped |
| 4. Implement repository layer | Doctrine models working; Eloquent models still functional |
| 5. Update tests | Hybrid setup tested; CI pipeline updated |
| 6. Deprecate Eloquent (optional) | All critical paths migrated; no Eloquent-specific features remain |
byteincoffee/doctrine-extensions for updates (low risk due to MIT license but high risk due to inactivity).doctrine/orm:validate-schema in CI.doctrine/doctrine-migrations-bundle for DB schema changes.PARTITION BY for soft deletes). Use doctrine/orm:query logging.__CG__* proxy classes; ensure they’re not excluded by OPcache.doctrine/cache) for read-heavy workloads.pdo_mysql connection pooling (eHow can I help you explore Laravel packages today?