softonic/laravel-middleware-request-id
Laravel middleware that assigns a unique request ID to every incoming request and response header, making it easy to trace requests through logs and distributed systems. Simple setup, configurable header name, and seamless Laravel integration.
Package shape: RequestId is a PSR-15/Laravel middleware that generates or propagates a correlation identifier and injects it into the response header. It is a thin, single-responsibility utility — not a framework, not a service, not a data-plane dependency. Scope is small enough to audit in a sitting, which materially lowers evaluation cost.
Architecture fit: High for any HTTP service that participates in distributed tracing, log correlation, or gateway-level request auditing. It slots into Laravel's global middleware stack without touching routing, container bindings, or service providers. The 3.0.1 fix — widening the handle() return type hint from Illuminate\Http\Response to Symfony\Component\HttpFoundation\Response and relying on covariance — is the correct architectural move: middleware must not narrow the response contract, because Laravel legitimately returns JsonResponse, RedirectResponse, StreamedResponse, and binary responses from the same pipeline.
Integration feasibility: Straightforward. Composer install, register middleware (globally or per-group), optionally publish config. No database, queue, cache, or external service dependency. The realistic effort is measured in hours, most of which is deciding where in the stack the middleware belongs and what to do with the ID downstream (log processor, outbound HTTP client propagation).
Technical risk:
Response. Any 3.0.0 pin is a latent runtime TypeError on JSON APIs — precisely the endpoints most likely to want request IDs. Pin >=3.0.1.HttpFoundation contract rather than Laravel's. That is a stable, slower-moving surface — a net risk reduction — but it does mean Symfony major bumps are the relevant upgrade signal, not Laravel's.Key questions:
X-Request-Id (or configurable header) when present, or always generate? Trust-boundary implications differ.Context/Log::withContext hook) or only to the response header?JsonResponse/RedirectResponse specifically — the exact case 3.0.1 fixes?Stack fit: Native. Targets Laravel 12 / Symfony 7; backwards-compatible in spirit with Laravel 10/11 provided the Symfony Response contract holds. No framework version conflict is introduced beyond what the app already requires.
Migration path: Greenfield — composer require at ^3.0.1, register in bootstrap/app.php (Laravel 11+ ->withMiddleware() style) as a global middleware ahead of application middleware and behind any trusted-proxy handling. Brownfield — confirm no existing correlation-ID implementation (many teams hand-roll this in a Log middleware); running both produces duplicate headers and ambiguous traces.
Compatibility: The 3.0.0 → 3.0.1 jump is a patch release with no API surface change for consumers; it is a bug fix that restores compatibility with non-Response return types. Treat 3.0.0 as unusable rather than merely buggy. Verify the app does not subclass or decorate RequestId; if it does, the parent return type change is a compile-time concern for the child.
Sequencing:
^3.0.1; add a lockfile and dependency-review gate so 3.0.0 cannot be resolved transitively.Maintenance: Near-zero surface area — one class, one config. Upgrade events are driven by Symfony HttpFoundation majors, roughly aligned with Laravel majors. Low churn, but also low signal: a package this quiet can go unmaintained without anyone noticing, so add it to a periodic dependency-review sweep rather than relying on organic awareness.
Support: No vendor SLA. Internal ownership should sit with the platform/observability team, since the artefact's value is realized in logging and tracing systems they operate, not in the application team that installs it. Document the header name and reuse rule as an internal standard.
Scaling: Effectively free. Per-request cost is ID generation and one header write; no I/O, no shared state, no contention. Scales horizontally without configuration. The only scaling consideration is cardinality in the logging backend if IDs are indexed as high-cardinality fields — a log-pipeline design concern, not a package one.
Failure modes:
Ramp-up: Minimal for an engineer familiar with Laravel middleware — under an hour to integrate, and the concept needs no explanation. The non-obvious learning is organizational, not technical: where the middleware sits in the stack, who owns the header contract, and how the ID reaches logs and outbound clients. Budget the coordination, not the coding.
Assessment caveat: This evaluation is derived from a single patch release note; no prior assessment, repository metadata, test coverage, or adoption data was available. Before promoting beyond a pilot, confirm maintainer activity, advisory history, and CI coverage of the JsonResponse/RedirectResponse cases this release addresses.
How can I help you explore Laravel packages today?