PHPackages                             pear/http\_request2 - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. pear/http\_request2

ActiveLibrary[HTTP &amp; Networking](/categories/http)

pear/http\_request2
===================

Provides an easy way to perform HTTP requests.

v2.7.0(1y ago)764.2M—0.9%6620BSD-3-ClausePHPPHP &gt;=5.6.0CI passing

Since Jan 12Pushed 1y ago16 watchersCompare

[ Source](https://github.com/pear/HTTP_Request2)[ Packagist](https://packagist.org/packages/pear/http_request2)[ Docs](https://pear.php.net/package/HTTP_Request2)[ RSS](/packages/pear-http-request2/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (13)Used By (20)Security (1)

HTTP\_Request2
==============

[](#http_request2)

[![Build Status](https://github.com/pear/HTTP_Request2/actions/workflows/continuous-integration.yml/badge.svg?branch=trunk)](https://github.com/pear/HTTP_Request2/actions/workflows/continuous-integration.yml)[![Static Analysis](https://github.com/pear/HTTP_Request2/actions/workflows/static-analysis.yml/badge.svg?branch=trunk)](https://github.com/pear/HTTP_Request2/actions/workflows/static-analysis.yml)

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](https://pear.php.net/package/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](https://pear.php.net/package/HTTP_Request2/) and has been migrated from [PEAR SVN](https://svn.php.net/repository/pear/packages/HTTP_Request2)

Please report all issues via the [GitHub issues](https://github.com/pear/HTTP_Request2/issues).

Pull requests are welcome.

Installation
------------

[](#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
-----------

[](#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
-------------

[](#documentation)

...is available on PEAR website

- Numerous [configuration options](https://pear.php.net/manual/en/package.http.http-request2.config.php)
- How to populate [the request object](https://pear.php.net/manual/en/package.http.http-request2.request.php)
- Description of [available adapters](https://pear.php.net/manual/en/package.http.http-request2.adapters.php)
- Processing of [HTTP response](https://pear.php.net/manual/en/package.http.http-request2.response.php)
- Monitoring the progress of request with [observers](https://pear.php.net/manual/en/package.http.http-request2.observers.php)
- Possible [exceptions](https://pear.php.net/manual/en/package.http.http-request2.exceptions.php)

[Generated API documentation](https://pear.php.net/package/HTTP_Request2/docs/latest/) for the current release is also there.

Testing, Packaging and Installing (Pear)
----------------------------------------

[](#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

```

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance46

Moderate activity, may be stable

Popularity58

Moderate usage in the ecosystem

Community40

Growing community involvement

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 92.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~455 days

Recently: every ~413 days

Total

10

Last Release

407d ago

PHP version history (2 changes)v2.2.0PHP &gt;=5.2.0

v2.4.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b43550745afa89d33e4b93f8535fc31c93ac0a712d264c13cb8f8c62d9198c1?d=identicon)[sad-spirit](/maintainers/sad-spirit)

---

Top Contributors

[![sad-spirit](https://avatars.githubusercontent.com/u/4820288?v=4)](https://github.com/sad-spirit "sad-spirit (243 commits)")[![CloCkWeRX](https://avatars.githubusercontent.com/u/365751?v=4)](https://github.com/CloCkWeRX "CloCkWeRX (9 commits)")[![gauthierm](https://avatars.githubusercontent.com/u/120511?v=4)](https://github.com/gauthierm "gauthierm (3 commits)")[![deliank](https://avatars.githubusercontent.com/u/5559223?v=4)](https://github.com/deliank "deliank (2 commits)")[![kenguest](https://avatars.githubusercontent.com/u/234118?v=4)](https://github.com/kenguest "kenguest (1 commits)")[![ktomk](https://avatars.githubusercontent.com/u/352517?v=4)](https://github.com/ktomk "ktomk (1 commits)")[![mensler](https://avatars.githubusercontent.com/u/6129516?v=4)](https://github.com/mensler "mensler (1 commits)")[![mrook](https://avatars.githubusercontent.com/u/477719?v=4)](https://github.com/mrook "mrook (1 commits)")[![phansys](https://avatars.githubusercontent.com/u/1231441?v=4)](https://github.com/phansys "phansys (1 commits)")[![howard](https://avatars.githubusercontent.com/u/26047?v=4)](https://github.com/howard "howard (1 commits)")

---

Tags

curlhttphttp-clienthttpclientphphttprequestcurlPEAR

### Embed Badge

![Health badge](/badges/pear-http-request2/health.svg)

```
[![Health](https://phpackages.com/badges/pear-http-request2/health.svg)](https://phpackages.com/packages/pear-http-request2)
```

###  Alternatives

[aplus/http-client

Aplus Framework HTTP Client Library

2161.6M1](/packages/aplus-http-client)[pdeans/http

PSR-7 cURL HTTP client with support for PSR-17 HTTP factories.

1466.2k3](/packages/pdeans-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
