Weave 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 Behaviors Laravel Package

toovalu-github/doctrine-behaviors

Doctrine Behaviors adds reusable entity traits and listeners to Doctrine ORM, including timestampable, sluggable, soft-deletable, blameable, and tree behavior, so common model logic stays out of your entities and your Laravel or PHP app stays clean.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • This is a Doctrine ORM 2 package, not an Eloquent package. Laravel ships Eloquent as the default ORM, so fit is conditional: it only applies if the application already runs Doctrine (typically via laravel-doctrine/orm) or is a Symfony/Doctrine codebase being partially migrated into a Laravel service.
  • The design is sound for Doctrine: behavior is delivered as traits + interfaces + event subscribers hooked into the Doctrine lifecycle (prePersist, onFlush, loadClassMetadata). That is idiomatic and low-intrusion — entities opt in per-behavior rather than inheriting a heavy base class.
  • Coverage is broad and maps to real product needs: audit trails (Loggable/Blameable), URL identity (Sluggable), GDPR-style retention (SoftDeletable), public-ID exposure (Uuidable), i18n (Translatable), and hierarchy (Tree). This is a "platform primitives" package, not a feature package — the value is in avoiding bespoke implementations of eight cross-cutting concerns.
  • Provenance matters: this is a fork of the long-established KnpLabs/DoctrineBehaviors. Technical quality is therefore inherited; the risk is in the fork, not the design.

Integration feasibility

  • Straightforward mechanically: Composer install, register the behavior subscribers on the Doctrine EventManager, add traits/interfaces to entities, and let doctrine:migrations:diff generate schema. No framework-specific bootstrapping required beyond the Doctrine service provider.
  • Non-trivial configuration surface:
    • Blameable needs a user-provider callable and correct behavior in queue/CLI contexts where no authenticated user exists.
    • Translatable requires a companion translation entity per translatable entity — a schema decision, not a config toggle.
    • Tree requires choosing and committing to a strategy (nested set vs. closure), which is expensive to reverse.
  • Two metadata drivers exist (annotations vs. PHP 8 attributes). Given a 2026-era release, plan on attributes; annotation support is legacy and interacts badly with newer Doctrine versions.

Technical risk

  • Ecosystem signal is the dominant risk. 0 stars and 0 dependents means no community buffer, no third-party bug reports, and no guarantee of responsiveness. A fork with an active-looking release date but no consumers is typically an internal patch published for convenience.
  • Supply-chain/provenance risk: an unaffiliated fork of a widely used package is a classic vector for silent divergence. You cannot assume the code is byte-identical to upstream without a diff.
  • Release metadata anomaly: the last release is dated 2026-04-21. Verify that this is a signed, tagged release on a stable branch rather than a CI artifact or branch alias — do not install a floating constraint against it.
  • Version-matrix risk: Doctrine ORM 3.x and DBAL 4.x changed metadata and type handling. A fork may lag upstream's compatibility work, pinning you to older Doctrine.
  • Behavioral risk is real, not theoretical: soft-delete filters leaking into queries, unique indexes colliding with soft-deleted rows, slug races under concurrency, and write amplification from Loggable all cause production incidents if adopted without guardrails.

Key questions

  1. Why does this fork exist? What is the diff against KnpLabs/DoctrineBehaviors at the corresponding tag, and is that diff a patch we need or an unreviewed divergence?
  2. Who owns this repository, what is the release cadence, and is there a stated upstream-sync policy?
  3. What is the tested compatibility matrix — PHP versions, Doctrine ORM/DBAL majors, and Laravel version via laravel-doctrine/orm?
  4. Is there a test suite and CI, and does it run against upstream's fixtures?
  5. If we adopt, do we consume this fork directly or consume upstream with our patch applied via cweagans/composer-patches? (The latter is usually the better answer.)
  6. Which of the eight behaviors do we actually need in the next two quarters? Adopting all eight at once multiplies schema and operational surface for little incremental value.

Integration Approach

Stack fit

  • Viable target: Laravel 10/11, PHP 8.1+, doctrine/orm 2.x (3.x only if the fork's CI proves it), laravel-doctrine/orm for the service provider and entity manager wiring.
  • Not viable in an Eloquent-first codebase without a deliberate decision to run a dual-ORM application. Dual-ORM means two identity maps, two transaction stories, and no shared unit of work — a cost that usually exceeds the benefit of any behavior package.
  • Best fit is a bounded context where Doctrine is already the persistence layer: a reporting domain, a CMS/i18n module, or a service extracted from a Symfony application.

Migration path

  • Treat this as an evaluation-first, patch-over-fork decision:
    1. Vendor audit: clone, diff against upstream tag, review the delta, run the test suite locally.
    2. Prefer knplabs/doctrine-behaviors + cweagans/composer-patches with the fork's delta as a tracked patch. This keeps you on the maintained upstream and makes the divergence visible in your repo.
    3. If the fork is consumed directly, pin to an exact tag or commit SHA in composer.json and add a Renovate/Dependabot rule that requires human review.
  • Introduce behaviors in risk order:
    • Wave 1 (low risk, high value): Timestampable, Uuidable, Sluggable — additive columns, easy to backfill, easy to roll back.
    • Wave 2 (moderate): Blameable, SoftDeletable — require query-filter discipline and a decision on unique-index semantics.
    • Wave 3 (high schema impact): Translatable, Tree — new tables and query-shape changes; require a design review before any migration is written.
    • Loggable is a separate decision gated on a retention and storage plan.

Compatibility

  • Verify trait collisions up front: Timestampable and Blameable both touch lifecycle timestamps; some Laravel-Doctrine bundles ship their own timestampable subscriber — registering both produces duplicate or double-written columns.
  • Confirm the metadata driver (attributes) and that doctrine/annotations is not required.
  • Confirm UUID storage: string vs. native uuid column type vs. binary. This must match your existing conventions or you will get cross-table join type mismatches.
  • Confirm migrations are generated, not hand-written, and reviewed for index/lock behavior on large tables.

Sequencing

  1. Fork diff + licensing/provenance review (MIT is fine; ownership is the question).
  2. Dependency-isolation spike: one bounded context, one behavior, one sprint.
  3. CI matrix job covering the app's PHP/Doctrine versions against the pinned package.
  4. Roll out waves 1→3 with a documented fallback (remove trait + revert migration) per wave.
  5. Only then consider Loggable with a retention policy.

Operational Impact

Maintenance

  • The fork becomes an internal dependency that needs an owner. Budget recurring effort to rebase on upstream, re-run the diff, and re-validate on every Doctrine major upgrade. If the delta is small, patches are cheaper than a fork; if the delta is large, ask why it was never upstreamed.
  • Schema churn is ongoing but predictable: each new translatable entity adds a table; each new tree entity adds strategy-specific columns. Provision for migration review capacity, not just initial setup.

Support

  • Upstream documentation is written for Symfony and applies only ~80% to a Laravel wiring. Expect to write internal docs for subscriber registration, user resolution for Blameable, and locale fallback.
  • With 0 stars, there is no community safety net. Escalation is internal or to the fork owner; plan accordingly and avoid this package on a critical path without a named maintainer.

Scaling

  • Loggable is write-amplifying (a row per changed field per change). Without retention/archival it becomes the largest table in the database within a year. Needs partitioning or a scheduled purge from day one.
  • Translatable adds a join per localized read, and multiplies rows by locale count. Watch index design on the translation table; hydrate-only-what-you-need or use partial selects.
  • Tree (nested set) makes reads cheap but writes contend on subtree updates — hot hierarchies serialize. If the domain has high write concurrency on the tree, evaluate a closure-table strategy or materialized path instead.
  • Sluggable performs an extra lookup per insert and needs a unique index plus retry-on-collision to be correct under concurrency.

Failure modes

  • Soft-delete filters silently disabled or bypassed → deleted records appear in listings, exports, and API responses.
  • Unique constraints colliding with soft-deleted rows → legitimate re-creation blocked.
  • Blameable null or stale in queue workers, console commands, and impersonation flows → audit trail becomes untrustworthy exactly when it matters.
  • Slug collisions under concurrent writes without a unique index and retry loop.
  • Translatable fallback-locale surprises in APIs (returning the wrong language silently rather than 404/406).
  • Tree corruption on concurrent moves; recovery requires a rebuild command that must be written and tested before launch.
  • Subscriber ordering conflicts with application-level Doctrine listeners.

Ramp-up

  • Doctrine literacy is the real cost: unit of work, DQL, metadata drivers, lifecycle events. A mid-level team should plan 1–2 sprints to be productive, more if Translatable and Tree are in scope.
  • Deliverables to pair with adoption: an internal runbook (subscriber config, user resolver, locale fallback), a migration-review checklist, and one worked example per behavior checked into the repo.
  • Overall posture: technically credible, ecosystem-immature. Evaluate, pin, isolate to a bounded context, and prefer upstream-plus-patch over direct dependency on a zero-consumer fork.
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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console