fabrizio-cafolla / response-http
Response service for Symfony & Laravel/Lumen Framework.
Installs: 169
Dependents: 0
Suggesters: 0
Security: 0
Stars: 14
Watchers: 2
Forks: 1
Open Issues: 0
Type:package
Requires
- php: >=7.1.3
- symfony/http-kernel: ^4.2
This package is auto-updated.
Last update: 2019-06-19 17:44:31 UTC
README
Let's go
Composer
composer require kosmosx/response
require __DIR__ . '/vendor/autoload.php';
$response = new Kosmosx\Response\RestResponse();
$handler = Kosmosx\Response\Exceptions\Handler();
$handler->setExceptionHandler();
use it
$response = new Kosmosx\Response\RestResponse($content, $status, $headers); //constructor
$response = new Kosmosx\Response\Factory\FactoryResponse::success(); //factory
$response->withData(true); //add to json array with key 'data'
Example
$response->success()
->withData(['test' => true])
->withData(['test2' => false])
->withMessage('Microservice Lumen work')
->withState();
//response
{
"data": {
"test": true,
"test2": false
},
"messages": "Microservice Lumen work",
"state": "OK"
}
en: documentation
it: documentazione
If you find a bug or want to contribute, write to developer@fabriziocafolla.com