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 Merge Persistent Collection Bundle Laravel Package

lenny4/doctrine-merge-persistent-collection-bundle

A Symfony bundle that provides a merge-persistent Doctrine collection, helping entities keep collection state across merges and reducing unexpected orphan removals during Doctrine entity merging operations.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit. Despite being filed here as a Laravel/PHP package, this is a Symfony bundle (*Bundle suffix, a DI extension, and service definitions) that changes Doctrine ORM behavior. There is no Laravel service provider, no Laravel-facing config, and no Eloquent integration. On a Laravel-first stack the packaging fit is effectively zero. The domain it addresses — correctly reattaching PersistentCollection associations when merging detached entities — is a real, well-known Doctrine Unit of Work sharp edge. So the honest read is: low packaging fit, plausible domain relevance, and only if Doctrine has been deliberately introduced into the Laravel app (DDD/hexagonal boundaries, or an incremental Eloquent→Doctrine migration). From a product standpoint this is not a "PHP package we can adopt"; it is reference material for a problem we may or may not have.

Integration feasibility. In Symfony this is a trivial registration. In Laravel it is not an integration — it is a bypass. We would have to ignore the bundle layer, instantiate the underlying merge service manually, bind it in a provider, and thread it through our repository/manager code. That consumes the package's internals, not its public contract, which is the most volatile surface it has. Realistically the only defensible route is to copy or adapt the merge logic into app/Support/Doctrine/ under MIT attribution and treat upstream as a reference. Feasible in an afternoon; not feasible as a live Composer dependency in a Laravel context.

Technical risk. High, but concentrated in project health rather than code complexity:

  • Adoption risk: 1 star, 0 dependents, score 0.005 — no production signal, no issue backlog as evidence of use, no third-party discussion to lean on.
  • Bus factor 1: a single maintainer, no visible CI/coverage/release cadence from the metrics we have.
  • Version drift: Doctrine ORM 3.x changed collection and Unit of Work semantics meaningfully; a small bundle pinned to ORM 2.x may simply not install on a modern stack. Composer constraint conflict is the likely first blocker, not a bug.
  • Silent-failure class: the cost of getting collection merging wrong is duplicated or lost child rows, which do not throw. From a TPM risk lens that is the worst category of dependency to accept unvetted, because it passes CI and surfaces weeks later in reporting or reconciliation.
  • Mitigating factors: MIT removes legal friction, and the surface area is small enough to audit fully in a couple of hours — which makes vendoring/adapting genuinely realistic.

Key questions to answer before any commitment.

  1. Can we reproduce the failing merge today — duplicate children after merge(), orphaned children surviving an update, or a cascade-merge exception on a nested collection? If not reproducible, we do not need the package.
  2. What are its composer.json constraints for PHP, doctrine/orm, and symfony/*, and does it install against our current versions at all?
  3. Does it have tests covering orphanRemoval, cascade: persist/merge, ordered collections (@OrderBy), composite keys, and both directions of bidirectional associations?
  4. Do we actually encounter cross-EntityManager merges in our architecture, or is this a problem we have inherited by assumption rather than observation?
  5. Is the need satisfiable with a few dozen lines of in-house collection diffing, or does it lean on Doctrine internals fragile enough that a maintained fork is preferable?
  6. Who is the maintainer, how recent are the commits, and is there any stated support commitment?

Integration Approach

Stack fit. Gate on one question first: is Doctrine ORM a sanctioned part of the stack? If the answer is "Laravel + Eloquent," close the evaluation here — the package is out of scope and there is nothing to migrate. If Doctrine is present or being introduced for a bounded context, proceed on the assumption that only the merge logic is portable and the Symfony bundle scaffolding is discarded. This is the pivotal decision point for a TPM: get it wrong and we burn a sprint integrating a package that has no business in our runtime.

Migration path. Recommend a spike-then-vendor path rather than a composer require:

  1. Reproduce the failing merge in a throwaway branch with a failing test that asserts collection integrity after EntityManager::merge().
  2. Evaluate the package against that test as a reference implementation, not an installed dependency. Read the merge strategy — likely identifier preservation and reconciliation by ID rather than clear-and-re-add, with orphanRemoval handled explicitly.
  3. If the logic is small and clean, reimplement it in application code with our own tests under MIT attribution. If it is non-trivial and correct, fork and vendor under our namespace so we own release cadence and can patch Doctrine 3 compatibility ourselves.
  4. Only consider a direct dependency if upstream shows recent commits, tests, and compatible constraints — none of which the current metrics suggest.

Compatibility. Verify three axes explicitly before any code is written: PHP minor version, doctrine/orm major (2.14+ vs 3.x), and doctrine/collections. Confirm the Symfony constraints aren't only satisfiable by Symfony 4/5 — on a modern PHP 8.2+ app that can block unrelated upgrades, because Composer resolves the whole graph even outside Symfony. Do not --ignore-platform-reqs past a conflict; that converts a dependency problem into a runtime problem and hands engineering a bug with no clean rollback.

Sequencing. Three-week bounded effort, not a quarter:

  • Week 1 — Validate the premise. Reproduce the bug, write the failing test, audit the package source (hours, not days). Gate: does the problem actually exist for us?
  • Week 2 — Prototype. Build the in-house/vendored implementation against the test; run it against a representative dataset including an upper-bound-sized association.
  • Week 3 — Decide and document. Build-vs-vendor call, record the Doctrine version we are pinned to, and file the decision. Default outcome remains "no new dependency."

Operational Impact

Maintenance. Treat as unmaintained-by-default. With 1 star and 0 dependents, expect no upstream fixes, no security response, and no Doctrine upgrade support. That means we own the code the moment it enters the repo: assign a named steward, register it in the dependency inventory with a review date, and attach a compatibility check to every Doctrine upgrade. The ongoing cost is modest given the small surface area, but it is non-zero and must be owned explicitly rather than assumed — this is the line item that turns a "free" MIT package into a small permanent commitment.

Support. No SLA, no vendor, no community. Troubleshooting is done by reading source. Mitigate by requiring the in-house test suite to cover the merge scenarios we depend on — that suite, not the package, becomes the actual support contract. Communicate this to stakeholders plainly: we are not buying support, we are buying a head start on edge cases and then supporting ourselves.

Scaling. Runtime cost is bounded by collection size: merging is O(n) per association and materializes whole collections in memory. On entities with large one-to-many associations this produces memory spikes and slow flush cycles. It does not scale differently from any Doctrine merge, but it concentrates cost at exactly the code path most likely to be hot in batch imports and queue consumers. Benchmark against a realistic upper-bound collection size before putting it behind a worker — the risk profile is not "it breaks," it's "it works and then falls over under load in a job nobody is watching."

Failure modes. Ranked by severity:

  1. Silent data corruption — duplicated child rows or dropped collection elements on flush. Highest severity because it is invisible until reporting or reconciliation catches it.
  2. Partial hydration — entity merged but association left stale or uninitialized, causing lazy-load surprises downstream.
  3. orphanRemoval interaction — merging triggers unintended deletes of children absent from the merged collection.
  4. Composer graph breakage — constraint conflicts blocking unrelated upgrades; low severity, high annoyance.
  5. Doctrine major-version breakage — silent behavioral divergence after an ORM upgrade, with no upstream fix forthcoming. Mitigations: post-merge assertions in fixtures, integration tests that count child rows before and after, and a pinned Doctrine version while the vendored code is in use.

Ramp-up. Low technical learning curve — a competent PHP engineer who understands Doctrine's Unit of Work can read the whole package in an afternoon. The real ramp-up is organizational: getting a decision on whether Doctrine is in scope, defining who owns the vendored code, and establishing the test coverage that substitutes for a support contract. Budget roughly one engineer-day to audit and prototype, plus test-writing around the affected entity graph. The dangerous cases — composite keys, orphanRemoval: true, ordered collections, bidirectional mappedBy/inversedBy — are where the time goes, and they are where the package's real value sits: it is a map of pitfalls, not a capability.

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.
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib