toneflix-code/laravel-resource-modifier
A Laravel package for modifying API resources on the fly, letting you add, remove, or transform fields in JsonResource responses without rewriting resource classes. Useful for tailoring API output per request, user role, or context.
meta block of Eloquent API Resource responses, which turns "should mobile get pagination counts?", "should partners see rate-limit hints?", "should white-label tenants see our brand in meta?" from a per-Resource-class code change into a configuration/policy decision. That is a product decision you can now make and reverse cheaply — provided your platform floor matches the package's (Laravel 12/13, PHP 8.3+; see below).JsonResource::wrap/additional convention, or spatie/laravel-data. The package's value is mostly as a reference implementation and a naming convention for your team.^8.3|^8.4 and Illuminate ^12.0|^13.0, and drops everything older. That makes adoption a platform roadmap decision, not just a code decision: it's only available to squads already on Laravel 12, or on a committed path to it. If half your fleet is on 10/11, this is not a per-squad convenience anymore — it's a fork or a wait.Adopt (or, more accurately, evaluate in a one-day spike) when all of these hold:
meta block. On Laravel ≤11 or PHP <8.3 you are looking at 1.1.5 (frozen, no stated support path) or a backport — which changes this from "evaluate" to "fork and own."additional()/with() on that resource is the right answer and this package is overhead.toneflix-code/laravel-resource-modifier → toneflix/laravel-resource-modifier, ToneflixCode\ResourceModifier → Toneflix\ResourceModifier, and the published config's import. If you adopt now, adopt the new namespace so you don't pay this twice.Look elsewhere when:
$hidden, whenLoaded, when(), or an explicit DTO layer. Meta-only interception won't cover it.spatie/laravel-data, API Platform).Executives: A small, MIT-licensed utility that lets us change the metadata wrapper on our API responses in one place instead of editing dozens of resource classes — useful for client-specific payloads, white-labeling, and deprecating meta fields without a v2 API. Cost is low and the code is small enough to own outright. Two caveats. First, the new 2.0 release raises the floor to Laravel 12/13 and PHP 8.3+, so it only fits squads already on, or committed to, that platform — it is not available to the rest of the fleet. Second, the release is a breaking rename of both the package and its PHP namespace, with no measurable adoption behind it, which confirms our earlier read: vendor it, don't depend on it. Decision requested: allow a one-sprint spike scoped to Laravel 12+ squads only, not a platform commitment.
Engineering: One interception seam for meta on Eloquent API Resources — good for tenant/client-type/request-context concerns that currently get copy-pasted across resources. It is not a serializer, not a field-hiding mechanism, and not visible to your OpenAPI spec, so contract tests need to cover whatever it emits. What changed in 2.0.0 matters for us: package renamed to toneflix/laravel-resource-modifier, namespace to Toneflix\ResourceModifier, require ^8.3|^8.4 PHP and ^12.0|^13.0 Illuminate, dev tooling bumped to Testbench 10/11 and Pest 4, CI matrix now covers only Laravel 12 and 13. Upgrade path is composer remove + composer require :^2.0, then rewrite imports and the published config — trivial if we own the code, annoying if we'd depended on it transitively. Given the adoption profile, plan to fork it into app/Support (or a private package) on day one using the 2.0 namespace, add tests, and pin the Laravel/PHP versions you support. The upside signal is real: a CI matrix against the current framework and a move to a proper vendor org suggests the maintainer is investing, not abandoning. If the spike shows we need more than meta mutation, we've learned cheaply that the real answer is a DTO/serialization layer.
How can I help you explore Laravel packages today?