boson-php/http-body-decoder
Lightweight HTTP request body decoder for PHP 8.4+. Decode incoming payloads by Content-Type (e.g., JSON, form data) into usable values, designed for Boson apps but usable standalone via Composer.
Request class and middleware stack, reducing architectural friction.Request class is critical (e.g., json()->all() vs. this package’s methods).HttpFoundation under the hood, so the PSR-7 adapter ensures compatibility. For Laravel <8, a custom bridge may be needed.Boson\Http\Middleware\DecodeBody) or via service provider, giving flexibility to decode bodies before Laravel’s default parsing.Request parsing (e.g., json(), input()). Key question: Does this package add value beyond Laravel’s defaults (e.g., custom formats like MessagePack, Protobuf)?Illuminate\Http\Request and Symfony\Component\HttpFoundation\Request.request()->json() in a single API endpoint with the package’s decoder.app/Http/Middleware/DecodeBody.php):
use Boson\Http\Middleware\DecodeBody;
protected $middleware = [
DecodeBody::class,
];
ConvertEmptyStringsToNull or TrimStrings middleware to avoid parsing conflicts.request()->cache(), ensure the package’s decoded data is cached correctly.input() is sufficient).| Scenario | Impact | Mitigation |
|---|---|---|
| Package stops working | API endpoints fail silently | Fallback to Laravel’s native parsing |
| Malformed body | 500 errors | Add validation middleware |
| PHP 8.4+ dependency | Breaks legacy Laravel apps | Use Docker/PHP versions manager |
| Boson ecosystem collapse | No updates | Fork the package internally |
How can I help you explore Laravel packages today?