fabrizio-cafolla / response-http
1.0.4
2019-06-19 17:43 UTC
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
让我们开始吧
Composer
composer require kosmosx/response
require __DIR__ . '/vendor/autoload.php';
$response = new Kosmosx\Response\RestResponse();
$handler = Kosmosx\Response\Exceptions\Handler();
$handler->setExceptionHandler();
使用它
$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'
示例
$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: 文档
it: 文档
如果您发现错误或希望贡献,请发送邮件至 developer@fabriziocafolla.com