crell/api-problem
A framework-agnostic PHP library implementing RFC 9457 (formerly RFC 7807) Problem Details for HTTP APIs. It provides structured problem objects, exceptions, and response helpers for consistent, machine-readable API error responses.
application/problem+json is the interoperable shape for API errors. Adopting it is a contract decision that outlives any framework choice, so it belongs in the API style guide, not in a sprint.type, title, status, detail, instance, plus extension members). It replaces a bespoke {error: {code, message}} shape that every team reinvents and every client SDK must special-case.type URI is a stable, documented identifier per error class. That gives you a versionable catalog of failure modes you can map to help-docs pages, support macros, and SDK exception classes — directly reducing "what does this error mean?" tickets.type/instance values make error dashboards and alert routing tractable instead of string-matching free-text messages.Adopt when:
HttpProblemException to Illuminate\Http\JsonResponse in the exception handler.NotFound, Unauthorized, ValidationFailed-style 4xx/5xx) rather than raw arrays, so error construction is compile-time checked and testable.Look elsewhere when:
ValidationException, AuthenticationException, ModelNotFoundException, and ThrottleRequestsException; or automatic Retry-After / WWW-Authenticate header handling. This library sets status and content type only — header semantics and framework exception translation are your adapter's job.To executives: One standard error format across our APIs. It shortens partner onboarding, cuts integration support tickets, and makes error responses self-describing so clients can react programmatically instead of parsing prose. Cost is low and reversible: a small MIT-licensed library plus a week of engineering to wire into the exception layer; the specification is public, so we are not locked in.
To engineering: RFC 9457-compliant typed value objects with named HTTP-status subclasses, an exception type implementing Throwable, arbitrary extension members for things like validation details and trace IDs, and a PSR-7 response factory that emits application/problem+json. Framework-agnostic by design; in Laravel we register renderables in the exception handler and produce a JsonResponse. Known gap: response headers (Retry-After, WWW-Authenticate) and framework exception mapping are ours to implement — budget for that explicitly rather than assuming it is included.
How can I help you explore Laravel packages today?