asispts/http-accept
A small PHP library for parsing HTTP Accept headers. It turns Accept, Accept-Language, Accept-Encoding and Accept-Charset values into usable objects, handles quality factors and wildcards, and helps you choose the best matching media type, language or encoding for a request.
Accept header parsing underpins decisions like "serve JSON vs. XML," "route to /api/v2," or "return 406 Not Acceptable" — capability that directly shapes public API contracts and client onboarding.Accept, Accept-Language, Accept-Encoding, quality values). Buying is cheap; building is a distraction from core roadmap work. The v1.0.0 stable tag lowers the "will this break under us" objection that typically blocks adoption of 0.x dependencies.Accept-Language, this package is a supporting enabler rather than a feature in itself — worth slotting in as a foundation item, not a roadmap line item.str_contains($request->header('Accept'), ...) checks scattered across controllers — a maintainability and correctness decision more than a feature decision.Adopt when:
q=0.8), wildcards (*/*, application/*), and multi-token headers — cases where naive string matching produces wrong results.Look elsewhere when:
Request::accepts(), Request::prefers(), and Symfony's AcceptHeader handle the common cases. If you only need "does the client accept JSON," do not add a dependency.willdurand/negotiation) or your framework's HTTP layer.v1.0.0-specific gating: The parser refactor plus the composer rename means this is a breaking release. Treat it as a fresh dependency evaluation, not a patch. Require the team to re-run negotiation edge-case tests against your actual client traffic before rollout.
To executives (30 seconds): We are evaluating a small open-source PHP component that lets our API correctly read what clients ask for — format, language, version — instead of guessing. It reached a stable 1.0 release this week. Cost is effectively zero, it removes a class of bug from our API surface, and it is easy to replace. The risk is that it is maintained by one person and just renamed its install package, so I recommend adoption only behind a thin internal wrapper so we can swap it out without touching product code.
To engineering leads: v1.0.0 is a stability signal but also a breaking change — the composer package name is now asispts/http-accept, and the parser was refactored in the same release. Before adopting, confirm whether Laravel's existing accepts()/prefers() already satisfy the requirement; if it does, we should not add the dependency. If we do adopt, wrap it in a single ContentNegotiation service, pin the exact version, and add tests for q-values, wildcards, and multi-token headers. Do not use it as a substitute for proper API versioning strategy.
Recommendation: Conditional adopt. Worth a timeboxed spike (~half a day) only if we have a concrete negotiation requirement that framework primitives cannot meet. Otherwise defer and revisit if the package gains adoption and a second maintainer.
How can I help you explore Laravel packages today?