2017 © Pedro PelĆ”ez
 

library laravel-apiresponse

Biblioteca de padronização de resposta em json

image

lucasandrade/laravel-apiresponse

Biblioteca de padronização de resposta em json

  • Saturday, June 18, 2016
  • by lucandrade
  • Repository
  • 1 Watchers
  • 2 Stars
  • 194 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 30 % Grown

The README.md

Laravel Api Response

Build Status Codacy Badge, (*1)

Standard API response to use with Laravel Framework, (*2)

Compatibility

Laravel PHP
5.0.x >= 5.4
5.1.x >= 5.5.9

Installation

Add the following line to your composer.json file:, (*3)

"lucasandrade/laravel-apiresponse": "dev-master"

Then run composer update to get the package., (*4)

Configuration - Laravel

Add this line of code to the providers array located in your config/app.php file:, (*5)

Lucandrade\ApiResponse\ApiResponseServiceProvider::class,

Add this line to the aliases array:, (*6)

'ApiResponse' => Lucandrade\ApiResponse\Facades\ApiResponse::class,

Run the vendor:publish command:, (*7)

php artisan vendor:publish

Configuration - Lumen

Execute this command from your project path:, (*8)

cp ./vendor/lucasandrade/laravel-apiresponse/src/config/apiresponse.php ./config

Uncomment the following line of your bootstrap/app.php file:, (*9)

\\ $app->withFacades();

Add this line in the end of file:, (*10)

$app->register(Lucandrade\ApiResponse\Lumen\ApiResponeServiceProvider::class);

Usage

Route::get('/api-response', function() {
    return ApiResponse::setPayload("Here's data")
        ->setStatusMessage("OK")
        ->setRequestCode(0)
        ->get();
});

Output:, (*11)

{
    "status":true,
    "payload":"Here's data",
    "message":"OK",
    "completed_at":"2015-09-02 16:27:11",
    "code":0
}

To change response fields alter apiresponse.php file located in your config directory:, (*12)

return [
    "keys" => [
        "status" => "{statusNameField}",
        "status_message" => "{messageNameField}",
        "request_code" => "{codeNameField}",
        "payload" => "{payloadNameField}",
        "time" => "{completedAtNameField}"
    ]
];

Note: remember to add use ApiResponse; to the beginning of the yours class file, (*13)

The Versions

18/06 2016

dev-master

9999999-dev

Biblioteca de padronização de resposta em json

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas Andrade de Oliveira

laravel framework api response json response

18/06 2016

1.3

1.3.0.0

Biblioteca de padronização de resposta em json

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas Andrade de Oliveira

laravel framework api response json response

18/06 2016

1.2

1.2.0.0

Biblioteca de padronização de resposta em json

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas Andrade de Oliveira

laravel framework api response json response

18/06 2016

1.1

1.1.0.0

Biblioteca de padronização de resposta em json

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas Andrade de Oliveira

laravel framework api response json response

18/06 2016

1.0

1.0.0.0

Biblioteca de padronização de resposta em json

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lucas Andrade de Oliveira

laravel framework api response json response