drewlabs / psr7
Psr7实现库
v0.2.4
2024-08-16 01:10 UTC
Requires
- php: >=7.0
- drewlabs/psr7-stream: ^2.0
- psr/http-message: ^1.0|^2.0
Requires (Dev)
- phpunit/phpunit: >=6.0
- psr/http-client: ^1.0
README
本包提供了Psr7请求、响应和URI接口的实现。
安装
使用composer
包管理器 [https://getcomposer.org.cn/download/].
composer require drewlabs/psr7
用法
- 创建Psr7类
drewlabs/psr7
包提供了一个Drewlabs\Psr7\Request
类,用于创建Psr7请求
use Drewlabs\Psr7\Request; // Instantiate the psr7 class $request = new Request(); // Overriding the request method $request = $request->withMethod('POST'); // Overriding request headers $request = $request->withHeaders([ // ... ]);
- 创建Psr7响应接口
drewlabs/psr7
包提供了一个Drewlabs\Psr7\Response
类,用于创建Psr7响应
use Drewlabs\Psr7\Request; // Instantiate the psr7 class $response = new Response(); // Instantiate response with parameters $response = new Response('', [/* Response headers */]); // Overriding the response method $response = $response->withStatusCode(404); // Overriding response headers $response = $response->withHeaders([ // ... ]);
- 创建Psr7 URI实例
drewlabs/psr7
包提供了一个Drewlabs\Psr7\Uri
类,用于创建Psr7 URI实例
$uri = Uri::new(/* URI string | or Null */);