foothing / uniform-json-responses
A PHP trait to uniform http responses.
0.1.0
2017-06-19 05:21 UTC
Requires
- php: >=5.5.0
- illuminate/http: ~5.1
Requires (Dev)
- codeclimate/php-test-reporter: dev-master
- mockery/mockery: 0.9.*
- phpunit/phpunit: 4.8.*
This package is auto-updated.
Last update: 2024-10-22 23:50:32 UTC
README
This is a tiny package meant to be used within Laravel.
It defines a trait
that can be used to wrap and uniform
JSON responses to a reusable format.
Install
composer require foothing/uniform-json-responses
Usage
Simply add the trait to your Controller and have your controller
actions to return content via the trait success
or fail
api.
class FooController { use WrapsResponses; public function getIndex() { // Do stuff return $this->success($dataToBeJSONed, 'Hey! It works.'); } public function putIndex() { // Do more bad stuff. return $this->fail("Doh, this is broken", 500); } }
The messages you can pass along with success
and fail
will be included in a X-Status-Message
header.