pear/http_request2
Composer 安装命令:
composer require pear/http_request2
包简介
Provides an easy way to perform HTTP requests.
README 文档
README
Provides an easy way to perform HTTP requests, uses pluggable adapters
- Socket: pure PHP implementation of HTTP protocol (does not use http stream wrapper), based on older PEAR HTTP_Request package
- Curl: wrapper around PHP's cURL extension
- Mock: used for testing packages depending on HTTP_Request2, returns predefined responses without network interaction
Both Socket and Curl adapters support POST requests with data and file uploads, basic and digest authentication, cookies, managing cookies across requests, HTTP and SOCKS5 proxies, gzip and deflate encodings, redirects, monitoring the request progress with Observers...
This package is PEAR HTTP_Request2 and has been migrated from PEAR SVN
Please report all issues via the GitHub issues.
Pull requests are welcome.
Installation
The package may be installed either with PEAR
$ pear install HTTP_Request2
or with composer
$ composer require pear/http_request2
Since release 2.4 composer installation relies completely on autoloading and does not contain require_once calls or
use include-path option.
Basic usage
require_once 'HTTP/Request2.php'; // Only when installed with PEAR $request = new HTTP_Request2('http://pear.php.net/', HTTP_Request2::METHOD_GET); try { $response = $request->send(); if (200 == $response->getStatus()) { echo $response->getBody(); } else { echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' . $response->getReasonPhrase(); } } catch (HTTP_Request2_Exception $e) { echo 'Error: ' . $e->getMessage(); }
Documentation
...is available on PEAR website
- Numerous configuration options
- How to populate the request object
- Description of available adapters
- Processing of HTTP response
- Monitoring the progress of request with observers
- Possible exceptions
Generated API documentation for the current release is also there.
Testing, Packaging and Installing (Pear)
To test, run
$ phpunit tests/
after installing dependencies with composer. You can also test the installed package with
$ phpunit [PEAR tests dir]/HTTP_Request2
Since PEAR package needs its require_once statements re-enabled, please run the helper file before packaging and
installing
$ php pear-package-helper.php
Then to build, simply
$ pear package .pear-package/package.xml
To install from scratch
$ pear install .pear-package/package.xml
To upgrade
$ pear upgrade -f .pear-package/package.xml
pear/http_request2 适用场景与选型建议
pear/http_request2 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.32M 次下载、GitHub Stars 达 76, 最近一次更新时间为 2014 年 03 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「PEAR」 「curl」 「http」 「request」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 pear/http_request2 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 pear/http_request2 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 pear/http_request2 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
cURL and cURL based Soap-Client for PHP
repository php library
Simple cURL wrapper
This is the Mysqli MDB2 driver.
A fluent PHP CURL wrapper
An implementation of the IMAP IDLE (RFC 2177) based on the pear/Net_IMAP
统计信息
- 总下载量: 4.32M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 78
- 点击次数: 18
- 依赖项目数: 63
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-03-05