iwf-web/json-request-check-bundle
iwf-web/json-request-check-bundle adds JSON request checking to Symfony applications, helping validate incoming JSON payloads before they reach your controllers. A small integration for more consistent API request handling.
Verdict: adopt the control, not the package. The problem space is legitimate; this specific artifact is a Symfony bundle with near-zero adoption, and the correct Laravel play is to reimplement the check as middleware or push it to the edge.
Architecture fit
kernel.request event and registers via a Bundle class plus a DI Extension/Configuration. Laravel has no bundle bootstrap; its HTTP kernel is a middleware pipeline with a different container and config model. There is no drop-in path.http-foundation, partially http-kernel), so a manual wire-up is theoretically possible, but you would be hand-registering an event subscriber outside the framework's normal lifecycle — fragile and unidiomatic.Content-Length, decode JSON with a depth cap, count top-level and nested keys, reject past thresholds. That is a ~50-line middleware in Laravel terms.Integration feasibility
Technical risk
max_input_vars does not apply to application/json bodies, so JSON endpoints genuinely lack key-count protection by default. That is the actual gap this package gestures at, and it is a few lines to close ourselves.Key questions
client_max_body_size, body-size limits)? If yes, the app-layer check is defense-in-depth, not the primary control.Stack fit
json_validate (PHP 8.3+) or json_decode(..., depth: N) for cheap structural validation; short-circuit on Content-Length before touching the body.TrustProxies/TrimStrings and before controller resolution and form-request validation, so malformed payloads never reach binding or validation cost.Migration path
LimitJsonPayload middleware — byte cap, top-level key cap, depth cap — returning a Laravel 413/422 with a stable error envelope. Do not install the bundle.Compatibility
HttpException semantics map to Laravel's handler; ensure rejections produce 413 Payload Too Large, not an uncaught 500.Sequencing
Instrument first (log Content-Length and key counts for 1–2 weeks) → set thresholds from p99.9 of legitimate traffic → ship edge limits → ship middleware in monitor-only mode → enforce → add regression tests with adversarial fixtures (deeply nested, wide-key, colliding-key).
Maintenance
Support
Scaling
Content-Length first and only decode when it passes; cap decode depth. Overhead is then negligible relative to the request.json_validate where available.Failure modes
500, poisoning client retry logic.Content-Length — need a fallback read cap.Ramp-up
How can I help you explore Laravel packages today?