2017 © Pedro Peláez
 

library laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

image

myerscode/laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

  • Thursday, May 10, 2018
  • by oniice
  • Repository
  • 1 Watchers
  • 1 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 50 % Grown

The README.md

Laravel API Response

A fluent helper to provide a consistent shaped API responses in Laravel, (*1)

Latest Stable Version Total Downloads License Tests codecov, (*2)

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!, (*3)

Install

You can install this package via composer:, (*4)

``` bash composer require myerscode/laravel-api-response, (*5)


## 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](https://laravel.com/api/master/Illuminate/Contracts/Support/Responsable.html) trait you dont need to do anything more than return the builder ### Using the api() helper function ```php 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., (*6)

{
    "status": 201,
    "data": {
        "name": "Foo Bar"
    },
    "meta": [],
    "messages": [
        "Record Created!"
    ]
}

License

The MIT License (MIT). Please see License File for more information., (*7)

The Versions

10/05 2018

dev-master

9999999-dev https://github.com/myerscode/laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

api response fluent consistent body idempotent

10/05 2018

1.0.0.1

1.0.0.1 https://github.com/myerscode/laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

api response fluent consistent body idempotent

10/05 2018

dev-develop

dev-develop https://github.com/myerscode/laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

api response fluent consistent body idempotent

08/05 2018

1.0.0

1.0.0.0 https://github.com/myerscode/laravel-api-response

A fluent helper and facade to ensure consistent, idempotent API responses in Laravel and Lumen

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

api response fluent consistent body idempotent