bhry98 / laravel-api-response
A fluent, extensible, and highly configurable API response toolkit for Laravel applications.
v2.0.0
2026-07-28 09:25 UTC
Requires
- php: ^8.2
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/pipeline: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
Requires (Dev)
- larastan/larastan: ^2.9|^3.0
- laravel/framework: ^11.0|^12.0|^13.0
- laravel/pint: ^1.17
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^2.34|^3.0
- pestphp/pest-plugin-laravel: ^2.4|^3.0
README
A fluent, extensible, highly configurable API response toolkit for Laravel 11, 12 and 13. Zero configuration to get started, endlessly customizable when you need it.
return api()->created($user); return api() ->success() ->message('User created.') ->data($user) ->meta(['foo' => 'bar']) ->headers(['X-Foo' => 'bar']) ->send();
📖 Full documentation
bhry98.github.io/packages/laravel-api-response
Installation
composer require bhry98/laravel-api-response
The service provider and the ApiResponse facade alias are auto-discovered - nothing else is required.
Highlights
- A single fluent builder (
api()/ApiResponse) with ready-made HTTP and business response shortcuts. - Fully configurable envelope - renameable keys, optional wrapping, and swappable
default/minimal/mobile/jsonapipresets. - Automatic data detection for models, collections, resources, paginators and DTOs.
- Global metadata, hooks, events, macros and a template system for reusable responses.
- Opt-in rate limiting middleware with a standard
api()->tooManyRequests()envelope. - Opt-in audit logging of requests/responses to the database via a queued job, so logging never slows down a response.
- Opt-in locale resolution middleware (
Accept-Languageheader first, then a configurable user locale column). - Optional exception handler and
response()->json()overrides, and testing assertion macros. - Fully backward compatible with the pre-2.0
BResponseSuccess/BResponseError/... API.
See the full documentation for configuration, usage examples and every extension point.
License
MIT.