Download the PHP package hasandotprayoga/format-response without Composer
On this page you can find all versions of the php package hasandotprayoga/format-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package format-response
Laravel Format Response For API
Installation
Add to composer.json
On your terminal, run composer update
Configuration
-
Open
app\Http\Controllers\Controller.php
, add one line like this: - Open
app\Exceptions\Handler.php
, edit method render like this:
How to use
Change your return response to $this->response();
$this->response($results, $resCode, $messages, $metaData, $request);
/*
@param $results default []
@param $resCode default 200
@param $messages default ''
@param $metaData default []
@param $request default []
*/
Example
return $this->response([1,2,4], 200, 'ok', [
'selectedPage' => 1,
'selectedItem' => NULL,
'totalPage' => 2,
'totalItem' => 5,
'totalItemPerPage' => 5
], [
'get'=>[
'field1'=>1,
'field2'=>2
],
'post'=>[]
]);
// Or
$this->results = [1,2,4];
$this->resCode = 200;
$this->messages = 'Ok';
$this->metaData = [
'selectedPage' => 1,
'selectedItem' => NULL,
'totalPage' => 2,
'totalItem' => 5,
'totalItemPerPage' => 5
];
$this->request = [
'get'=>[
'field1'=>1,
'field2'=>2
],
'post'=>[]
];
return $this->response();
Example Response
All versions of format-response with dependencies
PHP Build Version
Package Version
No informations.
The package hasandotprayoga/format-response contains the following files
Loading the files please wait ....