myerscode/laravel-api-response
| Install | |
|---|---|
composer require myerscode/laravel-api-response |
|
| Latest Version: | 13.0.1 |
| PHP: | ^8.5 |
| Laravel: | 13 |
| Older releases: | 11 |
| License: | MIT |
| Last Updated: | Oct 31, 2026 |
| Links: | GitHub · Packagist |
Laravel API Response
A fluent helper to provide a consistent shaped API responses in Laravel
Why is this package helpful?
This package ensures your API will always return the same envelope shape, so consuming apps always know what to expect!
Requirements
- PHP ^8.5
- Laravel ^13.0
Install
You can install this package via composer:
composer require myerscode/laravel-api-response
Usage
In a Laravel controller you just to build up your response and return it!
The api() helper return a Response Builder and as it implements the Responsable
trait you dont need to do anything more than return the builder
Using the api() helper function
function resource()
{
return api()->status(201)->data(['name' => 'Foo Bar'])->message('Record Created!');
}
Using a Builder class
function resource() {
$buillder = new Builder();
$builder->status(201)->data(['name' => 'Foo Bar'])->message('Record Created!');
return $builder;
}
Would return the following JSON response.
{
"status": 201,
"data": {
"name": "Foo Bar"
},
"meta": [],
"messages": [
"Record Created!"
]
}
License
The MIT License (MIT). Please see License File for more information.
Related Packages
Renders consistent HTTP JSON responses for API-based projects
Laravel API Manager Package - beatify and unify your responses with the least ef...
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 13.0.1 | ^8.5 | ^13.0 | MIT | |
| 13.0.0 | ^8.5 | ^13.0 | MIT | |
| 11.0.0 | ^8.2 | ^11.0 | MIT | |
| 8.0.0 | ^7.3| | MIT | ||
| 1.1.2 | ^7.1 | MIT | ||
| 1.1.1 | ^7.1 | MIT | ||
| 1.1.0 | ^7.1 | MIT | ||
| 1.0.1 | >=7.0 | MIT | ||
| 1.0.0.1 | >=7.0 | MIT | ||
| 1.0.0 | >=7.0 | MIT |