Guzzle
Guzzle 是一个 PHP HTTP 客户端,致力于让发送 HTTP 请求以及与 Web 服务进行交互变得简单。
Github:https://github.com/guzzle/guzzle
Composer:https://packagist.org/packages/guzzlehttp/guzzle
发送请求
use GuzzleHttp\Client;
$client = new Client([
//跟域名
'base_uri' => 'http://localhost/test',
// 超时
'timeout' => 2.0,
]);
$response = $client->get('/get'); //http://localhost/get
$response = $client->delete('delete'); //http://localhost/get/delete
$response = $client->head('http://localhost/get');
$response = $client->options('http://localhost/get');
$response = $client->patch('http://localhost/patch');
$response = $client->post('http://localhost/post');
$resp