v0.3.0 2019-03-28 15:18 UTC

This package is not auto-updated.

Last update: 2024-04-13 17:35:25 UTC


README

安装

composer require ant-framework/http

创建一个请求

include "vendor/autoload.php";

$request = new \Ant\Http\Request('GET','http://www.example.com');

echo $request;

//output ..
/*
GET / HTTP/1.1
Host: www.example.com


*/

创建一个响应

include "vendor/autoload.php";

$response = new \Ant\Http\Response();

// 选择装饰器,设置内容,装饰response
$response = $response->selectRenderer('json')
    ->setPackage(['foo' => 'bar'])
    ->decorate($response);

echo $response;
//output ..
/*
HTTP/1.1 200 OK
Content-Type: application/json;charset=utf-8

{"foo":"bar"}
*/