quibax/http
Composer 安装命令:
composer require quibax/http
包简介
Fork from vinelab/http with some adjustments for own use.
README 文档
README
http://Client
A smart and simple HTTP client for sending and recieving JSON and XML.
Installation
Composer
"vinelab/http": "dev-master"or refer to vinelab/http on packagist.org for the latest version installation instructions.
// change this to point correctly according // to your folder structure. require './vendor/autoload.php'; use Vinelab\Http\Client as HttpClient; $client = new HttpClient; $response = $client->get('echo.jsontest.com/key/value/something/here'); var_dump($response->json());
Laravel
Edit app.php and add 'Vinelab\Http\HttpServiceProvider', to the 'providers' array.
It will automatically alias itself as HttpClient so no need to alias it in your app.php, unless you would like to customize it - in that case edit your 'aliases' in app.php adding 'MyHttp' => 'Vinelab\Http\Facades\Client',
Usage
GET
Simple
$response = HttpClient::get('http://example.org'); // raw content $response->content();
With Params
$request = [ 'url' => 'http://somehost.net/something', 'params' => [ 'id' => '12350ME1D', 'lang' => 'en-us', 'format' => 'rss_200' ] ]; $response = HttpClient::get($request); // raw content $response->content(); // in case of json $response->json(); // XML $response->xml();
POST
$request = [ 'url' => 'http://somehost.net/somewhere', 'params' => [ 'id' => '12350ME1D', 'lang' => 'en-us', 'format' => 'rss_200' ] ]; $response = HttpClient::post($request); // raw content $response->content(); // in case of json $response->json(); // XML $response->xml();
Headers
$response = HttpClient::get([ 'url' => 'http://some.where.url', 'headers' => ['Connection: close', 'Authorization: some-secret-here'] ]); // The full headers payload $response->headers();
Enforce HTTP Version
HttpClient::get(['version' => 1.1, 'url' => 'http://some.url']);
Raw Content
HttpClient::post(['url' => 'http://to.send.to', 'content' => 'Whatever content here may go!']);
Custom Query String
The content passed in the content key will be concatenated to the URL followed by a ?
HttpClient::get(['url' => 'http://my.url', 'content' => 'a=b&c=d']);
It is pretty much the same process with different HTTP Verbs. Supports
GET, POST, PUT, DELETE, PATCH, OPTIONS, HEAD
TODO
- Improve tests to include testing all the methods of response (like statusCode...)
- Include tests for handling bad data / errors
- Improve tests to include testing for all HTTP Verbs
quibax/http 适用场景与选型建议
quibax/http 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 232 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「curl」 「json」 「xml」 「http」 「api」 「client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 quibax/http 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 quibax/http 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 quibax/http 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
Simple cURL wrapper
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
Load DOM document safety
统计信息
- 总下载量: 232
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-04-04