rikudou/array-merge-recursive
A lightweight PHP utility for recursively merging arrays with predictable results. It combines nested structures while letting later values take precedence, making it useful for configs, defaults, and deep data composition. Framework-agnostic and easy to use.
array_merge_recursive answers "turn the scalar into an array and append," which is almost never what a product wants. This package answers "last writer wins, recursively." Choosing that semantic explicitly is a product decision, not just a technical one — it determines whether a tenant override replaces or pollutes a default.Arr::merge already implements replace-style deep merge, and has for years. The PM-relevant output is "standardize on the framework primitive and document it," which removes a category of inconsistency from code review.Consider it when:
array_merge_recursive wrapping scalars into arrays.composer require, given the maintenance signal.Look elsewhere when:
Arr::merge covers this; adding a dependency is pure overhead.To executives: This is a small, free utility that fixes a specific and recurring class of configuration bug — the kind where a tenant's override silently turns a setting into a list instead of replacing it. It is not a platform investment and should not appear on a roadmap. The recommendation is almost certainly not to adopt the package, but to adopt its one-line semantic decision (replace, don't append) as a documented standard. Cost: near zero. Risk: near zero. Benefit: fewer subtle environment-specific defects and faster diagnosis when configs disagree.
To engineering: The library is a drop-in replacement for array_merge_recursive with replace semantics. Before adding it: if we're on Laravel, Arr::merge already does this and we should use it and say so in the style guide. If we're not, vendor a small internal helper with tests rather than pulling in a 2021-abandoned package with zero dependents and an unusual license. Either way, write the merge contract down — "nested keys are replaced, not appended, at every depth" — and cover it with a test, because that sentence is the actual deliverable here.
How can I help you explore Laravel packages today?