netbull/doctrine-behaviors
Doctrine behavior extensions for Laravel, adding reusable traits and listeners for common ORM patterns like timestamps, slugs, soft deletes, and blameable fields, so models stay clean and consistent with minimal boilerplate.
Architecture fit: This is not a Laravel/Eloquent package; it is a Doctrine ORM behavior library. It fits only if the Laravel application already uses Doctrine via laravel-doctrine/orm, doctrine/orm directly, or a Doctrine-based legacy/service layer. In an Eloquent-first Laravel codebase, the architectural mismatch is high: Laravel’s native patterns already cover timestamps, soft deletes, UUIDs, and often slugs, while this package expects Doctrine entities, metadata drivers, and event subscribers. The package is most leverageable as a boilerplate reducer for cross-cutting entity concerns in a Doctrine-backed Laravel service, not as a general Laravel dependency.
Integration feasibility: Technically feasible with Composer and Doctrine event/subscriber configuration, but not “drop-in” Laravel integration. The TPM should expect to wire behavior subscribers/listeners, validate entity mapping conventions, and confirm schema impacts for Translatable, Tree, Loggable, and SoftDeletable. Each behavior has non-trivial data-model implications: translation tables, audit tables, nested-set/tree columns, soft-delete filters, blameable user references, and UUID column types. Integration effort is medium in a Doctrine app and high/irrelevant in an Eloquent app.
Technical risk: Adoption signals are weak: 0 stars, 0 dependents, and a low package score. The MIT license is favorable, but community support and production evidence are effectively absent. The main risks are compatibility with current Doctrine ORM and PHP versions, maintenance continuity, undocumented behavior interactions, and silent misconfiguration. Translatable and Tree behaviors in particular can create schema and query complexity that is difficult to reverse later. The package should be treated as a small-vendor or fork-grade dependency requiring a compatibility spike and an exit plan.
Key questions: Does the target app use Doctrine ORM or Eloquent? Which Doctrine ORM, PHP, and Laravel versions are supported? Are PHP attributes supported, or only annotations/XML/YAML mapping? Which behaviors are actually needed, and can Laravel-native or existing Doctrine extensions cover them? Who maintains the fork/package, and is there a tagged release history with tests? What are the migration and rollback paths for Translatable, Tree, and Loggable schema changes? Is the package compatible with Doctrine ORM 3.x and PHP 8.x?
Stack fit: Use only in a Laravel application whose persistence layer is Doctrine ORM. Do not introduce Doctrine solely to use this package. If the app is Eloquent-based, map requirements to Laravel-native features or first-party packages instead: timestamps, SoftDeletes, UUID/ULID keys, slug packages, and audit/logging packages. If the app is Doctrine-based, this package can reduce repetitive entity code for Blameable, Timestampable, Sluggable, SoftDeletable, Uuidable, Loggable, Translatable, and Tree.
Migration path: Start with a bounded spike on one non-critical entity, preferably Timestampable/Blameable/Uuidable. Then validate SoftDeletable filters and Sluggable uniqueness before considering Loggable or Translatable. Treat Tree as a separate, higher-risk migration because it changes storage and query patterns. For existing data, create Doctrine migrations with explicit backfill scripts, nullability decisions, and rollback steps. Avoid enabling multiple behaviors on the same entity without testing event ordering and schema generation.
Compatibility: Build a compatibility matrix covering PHP version, Doctrine ORM version, Doctrine DBAL version, Laravel version, and the Laravel-Doctrine bridge if used. Confirm metadata driver support: attributes are preferable for modern PHP; annotation support is a legacy risk. Validate database platform differences, especially UUID storage, JSON/log columns, timestamp precision, and tree index requirements. Pin the package version and commit hash in composer.lock; avoid floating constraints.
Sequencing: First, decide Doctrine vs. Eloquent and document the decision. Second, run a technical spike with one entity and one behavior. Third, validate schema generation and migrations in a staging database. Fourth, add behaviors incrementally, with tests for listener registration, soft-delete filtering, translation fallback, audit writes, and tree integrity. Fifth, establish an internal fork/vendor contingency before production adoption. Sixth, only then expand to additional entities.
Maintenance: Low external maintenance confidence. With 0 stars and 0 dependents, the TPM should assume the package may need internal ownership. Budget for dependency review, compatibility patching, and regression tests around Doctrine upgrades. The MIT license permits forking, but forking transfers maintenance burden to the team. Document all enabled behaviors and their entity-level configuration so future engineers can trace schema and listener behavior.
Support: Community support is effectively absent. Rely on internal expertise, Doctrine documentation, and source review rather than upstream issue response. Establish an internal support owner and a decision record for each behavior used. For critical entities, prefer explicit code over opaque behavior traits when the behavior’s query or schema impact is not well understood.
Scaling: Event-subscriber behaviors add write-path overhead. Loggable can significantly increase write volume and table size; Translatable increases joins and fallback logic; Tree operations can introduce write contention and costly moves. SoftDeletable filters must be consistently applied or queries may leak deleted records or degrade performance. Plan for indexing, retention policies for logs, and query review for translation and tree access patterns.
Failure modes: Common failure modes include subscribers not registered so behaviors silently do nothing; schema drift between generated metadata and migrations; soft-deleted records appearing in reports; missing or null blameable users in CLI/queue contexts; timezone inconsistencies in timestamps; translation fallback errors; UUID format mismatches across databases; audit-log growth; and tree corruption after bulk updates. Translatable and Tree failures are the most expensive because they affect data model correctness, not just convenience.
Ramp-up: Ramp-up is high for Eloquent-centric teams because they must learn Doctrine entity mapping, metadata, event subscribers, Doctrine migrations, and behavior-specific conventions. For teams already proficient in Doctrine, ramp-up is moderate. Provide a short internal guide covering enabled behaviors, listener registration, migration commands, test patterns, and troubleshooting. Keep the initial adoption narrow and measurable: fewer behaviors, fewer entities, explicit rollback plans, and a clear owner.
How can I help you explore Laravel packages today?