lukasoppermann/http-status
lukasoppermann/http-status is a lightweight PHP package providing constants and helpers for standard HTTP status codes, including reason phrases and code validation. It makes API and web response handling more readable and consistent without extra dependencies.
Install with Composer:
composer require lukasoppermann/http-status
This is a small utility package, not a full Laravel integration: expect a static Httpstatus class rather than a service provider, facade, publishable config, or migrations. Start by reading the README and the package source to confirm the exact static method names and supported languages. The v4.0.0 release is notable for two practical additions: German is now accepted by Httpstatus::setLanguage('de'), and the 425 status code entry has been completed.
First use case: use it in an API exception handler or response helper to keep status text consistent:
Httpstatus::setLanguage('de');
$message = Httpstatus::getMessage(425); // confirm exact lookup method in the README
return response()->json([
'message' => $message,
], 425);
For Laravel, the quickest win is wrapping the package in a small application service, then using that service from bootstrap/app.php, an exception renderer, or API middleware.
HttpStatusMessage service or helper that wraps Httpstatus. This keeps package calls out of controllers and makes it easy to change localization or fallback behavior later.Handler, map HTTP status codes to package-provided messages for JSON responses. Keep your machine-readable error codes separate from the human-readable status message.app()->getLocale() in middleware, then reset it after the request. This is especially important in long-running workers and Laravel Octane.Retry-After.setLanguage is static/global state. In PHP-FPM this is usually harmless, but in Octane, queues, or long-running processes a language change can leak into later requests. Set and reset it explicitly per request or avoid changing it dynamically.de; other values may fall back or behave unexpectedly depending on the package implementation. Validate locale mapping in your wrapper.How can I help you explore Laravel packages today?