Download the PHP package maksudur-dev/laravel-api-response without Composer
On this page you can find all versions of the php package maksudur-dev/laravel-api-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download maksudur-dev/laravel-api-response
More information about maksudur-dev/laravel-api-response
Files in maksudur-dev/laravel-api-response
Package laravel-api-response
Short Description A lightweight Laravel package to standardize API JSON responses.
License MIT
Homepage https://github.com/maksudur-dev/laravel-api-response
Informations about the package laravel-api-response
Laravel API Response Standardizer
A professional, production-ready Laravel package to standardize your API JSON responses. Developed by Maksudur Rahman.
Features
- PSR-4 Compliant: Clean, object-oriented structure.
- Multiple Usage Patterns: Use Facades, Traits, or Global Helpers.
- Fully Configurable: Customize response keys (status, message, data, etc.) to match your needs, including
status_code/status_message. - Standardized Pagination: Automatic formatting for Laravel's Paginator.
- Zero Configuration: Works out of the box, but highly customizable.
- Compatible: Supports Laravel 8, 9, 10, 11, 12, and 13.
Installation
You can install the package via composer:
Configuration (Optional)
If you want to customize the response keys, publish the config file:
This will create a config/api-response.php file where you can change the keys:
For example, you can customize your response fields to use status_code and status_message instead of the default status and message keys.
Usage
1. Using Facade (Recommended)
2. Using Trait (Best for Controllers)
Add the HasApiResponse trait to your controller:
3. Using Global Helpers
Response Formats
Success Response
Error Response
Pagination Response
Custom Key Response
If you change the config keys, your JSON response can instead use names like status_code and status_message:
License
The MIT License (MIT). Please see License File for more information.