hraw/httpclient
最新稳定版本:v1.0.0
Composer 安装命令:
composer require hraw/httpclient
包简介
A simple and easy to implement wrapper for PHP cURL
README 文档
README
A simple and easy to implement wrapper for PHP cURL.
Requirements
- PHP 7.0 or higher
- Composer for installation
Supported Methods:
- GET
- POST
- PUT
- PATCH
- DELETE
Installation
composer require hraw/httpclient
Implementation
<?php use Curl\HttpClient; $response = HttpClient::get('https://jsonplaceholder.typicode.com/todos')->send();
In response, it returns the instance of CurlResponse class.
<?php //Get the data returned by api $response->data(); //Get status code $response->statusCode(); //Check if response received is success response or not $response->success(); //Get all the properties returned in response $response->properties();
You can also add headers and timeout value while doing the curl request
HttpClient::get($url) ->timeout(60) ->headers([ 'Content-Type : application/json', 'Authorization : Bearer {token}' ]) ->send();
POST Request
HttpClient::post($url, $data)->send();
- PUT and PATCH method has same implementations as POST method.
- DELETE method has same implementation as GET method.
统计信息
- 总下载量: 489
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-10-15