pharaonic / laravel-api-response
Consistent Laravel API responses: one envelope for success and error responses, resources and every paginator, with profiles, notifications, request IDs and opt-in exception rendering.
13.2.0
2026-11-26 15:17 UTC
Requires
- php: >=8.3 <8.6
- illuminate/container: ^13.0
- illuminate/contracts: ^13.0
- illuminate/http: ^13.0
- illuminate/pagination: ^13.0
- illuminate/support: ^13.0
Requires (Dev)
- laravel/pint: ^1.20
- orchestra/testbench: ^11.0
- pestphp/pest: ^4.0
- phpstan/phpstan: ^2.1.33
- phpunit/phpunit: ^12.5.8
Suggests
- pharaonic/laravel-seo: Adds the page's SEO tags to a response that calls withSEO() (13.1 or later).
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-26 15:18:37 UTC
README
One consistent envelope for Laravel API responses: success and error responses, resources and every paginator, with profiles, notifications, request IDs and opt-in exception rendering.
Installation
composer require pharaonic/laravel-api-response
The service provider is registered automatically. Publish the configuration when you need to change it:
php artisan vendor:publish --tag=api-response-config
Messages follow the application locale (English and Arabic included). Publish them to change a line or add a language:
php artisan vendor:publish --tag=api-response-translations
Usage
use App\Http\Resources\PostResource; use App\Models\Post; use Pharaonic\Laravel\ApiResponse\Response; class PostController { public function index() { return Response::success(PostResource::collection(Post::query()->paginate(15))) ->message('Posts retrieved.') ->notify('Posts loaded.', 'success', title: 'Posts'); } public function show($id) { return Response::error('Post not found.', 404); } }
Documentation
Full documentation: Laravel API Response Documentation.
Support & Security
See SUPPORT.md and SECURITY.md. Contributions are welcome; see CONTRIBUTING.md.
License
MIT. See LICENSE.
