Looking to hire Laravel developers? Try LaraJobs

laravel-response maintained by fbpkg

Description
Fluent response builder for Laravel APIs with clean and consistent JSON structure
Last update
2026/07/16 13:47 (dev-main)
License
Downloads
7

Comments
comments powered by Disqus

Laravel Response

Fluent response builder for Laravel APIs with clean and consistent JSON structure.


Installation

composer require fbpkg/laravel-response

Usage

Basic success response

return LaravelResponse::success('OK')
    ->data($user)
    ->send();

Error response

return LaravelResponse::error('Something went wrong', 500)
    ->send();

Validation response

return LaravelResponse::error('Validation failed', 422)
    ->validation($validator)
    ->alert('warning', 'Please fix errors')
    ->send();

Output Example

{
  "status": "error",
  "message": "Validation failed",
  "meta": {
    "validation": {
      "email": ["Email is required"]
    },
    "alert": {
      "type": "warning",
      "message": "Please fix errors"
    }
  }
}

License

MIT