programster / guzzle-wrapper
一个库,用于简化使用Guzzle发送HTTP请求。
1.1.0
2020-12-28 17:11 UTC
Requires
- php: >=7.0.0
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- irap/autoloader: 1.0.*
- irap/core-libs: ^1.1
README
一个围绕Guzzle的库,以便更容易发送HTTP请求。如果您需要做更复杂的事情,则可以在其中获取Guzzle对象。
示例用法
$request = new Programster\GuzzleWrapper\Request( Programster\GuzzleWrapper\Method::createGet(), 'http://my.domain.com', ['hello' => 'world'] ); // send the request to get a response $response = $request->send(); // If we were sending to an API, then we want to json_decode the response $jsonResponseObject = json_decode($response->getBody());
切换到POST/PUT/DELETE只需一行代码。例如:
$request = new Programster\GuzzleWrapper\Request( Programster\GuzzleWrapper\Method::createPost(), 'http://my.domain.com', ['hello' => 'world'] );
测试
进入测试文件夹并运行:
php -S localhost:80 RequestDumper.php
然后使用以下命令执行测试:
php main.php
这将简单地告诉您每个测试是否通过。