fabrizio-cafolla/response-http

此包已被弃用且不再维护。作者建议使用kosmosx/response包代替。

Symfony & Laravel/Lumen 框架的响应服务。

1.0.4 2019-06-19 17:43 UTC

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