fbpkg/laravel-response

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

Maintainers

Package info

github.com/fbpkg/laravel-response

pkg:composer/fbpkg/laravel-response

Statistics

Installs: 6

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-06-29 06:29 UTC

This package is not auto-updated.

Last update: 2026-06-30 05:22:03 UTC


README

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