ezijing / http-request-utils
hyperf http请求工具包
v1.0.7
2022-11-01 02:56 UTC
Requires
- php: >=7.3
- hyperf/di: 2.2.*
- hyperf/framework: 2.2.*
- hyperf/guzzle: ^2.2
- hyperf/utils: ^2.2
- psr/container: ^2.0
- psr/http-message: ^1.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.0
- phpstan/phpstan: ^1.0
- phpunit/phpunit: >=7.0
- swoole/ide-helper: ^4.5
Suggests
- swow/swow: Required to create swow components.
README
一、安装
命令
> composer require ezijing/http-request-utils
二、使用
<?php declare(strict_types=1); namespace HyperfTest\Cases; use Hyperf\HttpRequest\BaseRequest; use Hyperf\HttpRequest\Request; use PHPUnit\Framework\TestCase; /** * @internal * @coversNothing */ class RequestTest extends TestCase { protected $request; protected function setUp(): void { $this->request = make(Request::class); } public function testRequestSend() { $url = 'https://XXX/growth_api/v1/lottery_config/get'; $data = [ 'aid' => '6587', 'uuid' => '7039128193925088782', ]; $cookies = [ 'a' => 1, ]; $headers = ['response_str' => true]; $result = $this->request ->getInstance(BaseRequest::GET_METHOD) ->withUrl($url) ->withRequestData($data) ->withCookies($cookies) ->withHeaders($headers) ->request(); $this->assertIsArray($result); print_r($result); } }