PHPackages                             novotnyj/http-helper - 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. novotnyj/http-helper

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

novotnyj/http-helper
====================

Object oriented cURL in PHP.

2.0.0(11y ago)138BSD-3-ClausePHPPHP &gt;=5.3.1

Since Feb 7Pushed 10y ago1 watchersCompare

[ Source](https://github.com/novotnyj/http-helper)[ Packagist](https://packagist.org/packages/novotnyj/http-helper)[ Docs](https://github.com/novotnyj/http-helper)[ RSS](/packages/novotnyj-http-helper/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

HttpHelper
==========

[](#httphelper)

This PHP library was created as an alternative to the pecl\_http. Goal was to make working with cURL easier and object oriented.

Basic methods has names similar to pecl\_http HttpRequest. This should make switching between pecl\_http and HttpHelper easier.

HttpHelper\\Request is using cURL - make sure that you have cURL extension enabled in php.ini

Requirements
------------

[](#requirements)

HttpHelper requires PHP 5.3.1 or later with php5-curl installed.

Instalation
-----------

[](#instalation)

HttpHelper can be installed using [Composer](https://getcomposer.org/). Package can be found in [Packagist](https://packagist.org/packages/novotnyj/http-helper) repository.

```
composer require novotnyj/http-helper

```

Usage examples
--------------

[](#usage-examples)

### Get request

[](#get-request)

You can send HTTP request simillar to pecl\_http:

```
use HttpHelper\Request;

$request = new Request("http://www.google.com");
$request->send();
if ($request->getResponseCode() == 200) {
	echo $request->getResponseBody();
}
```

Or you can use HttpHelper\\Response object returned by send method. Also wrap send method in try/catch block in case something went wrong:

```
...
try {
	$response = $request->send();
	if ($response->getCode() == 200) {
		echo $response->getBody();
	}
} catch (RequestException $e) {
	echo $e->getMessage();
}
```

### Post request

[](#post-request)

To send a post request change method to POST

```
use HttpHelper\Request;

$request = new Request("http://www.foo.com/sign/in", Request::POST);
$request->setPostFields(array(
	'login' => 'user',
	'password' => 'p4ssW0rd'
));
try {
	$response = $request->send();
	if ($response->getCode() == 200) {
		echo $response->getBody();
	}
} catch (RequestException $e) {
	echo $e->getMessage();
}
```

To send a file using POST request:

```
...
$request->setMethod(Request::POST);
$request->setPostFields(array(
	'upload' => '@/absolute/path/to/file.ext'
));
...
```

To send a JSON POST request:

```
...
$request->setMethod(Request::POST);
$request->setJSON(array(
	'login' => 'foo'
));
...
```

### Follow redirects

[](#follow-redirects)

To enable automatic following Location header (for 301, 302 and 303 response codes):

```
...
$request->enableRedirects();
...
```

By default this will follow Location only 20 times. After that RequestException will be raised from send method. You can pass different limit as parameter to enableRedirects (0 means follow Location infinite times). To follow Location for 999 times:

```
$request->enableRedirects(999);
```

**Note:** This function is not using CURLOPT\_FOLLOWLOCATION, so you should be fine even with open\_basedir or safe\_mode in your php.ini

### Use response cookies

[](#use-response-cookies)

To enable automatic using of response cookies for next request:

```
...
$request->enableCookies();
...
```

NOTE: filtering response cookies by expiration date is not implemented yet.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~63 days

Total

8

Last Release

4030d ago

Major Versions

1.0.6 → 2.0.02015-04-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/ea62d77318a44c56d58bfe9b04defaa9d8a645c549e28283931a0a8526022a30?d=identicon)[novotnyj](/maintainers/novotnyj)

---

Top Contributors

[![novotnyj](https://avatars.githubusercontent.com/u/1233185?v=4)](https://github.com/novotnyj "novotnyj (53 commits)")

---

Tags

httpphp

### Embed Badge

![Health badge](/badges/novotnyj-http-helper/health.svg)

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

###  Alternatives

[hannesvdvreken/guzzle-debugbar

A Guzzle middleware that logs requests to debugbar's timeline

76410.4k1](/packages/hannesvdvreken-guzzle-debugbar)[swoole-bundle/swoole-bundle

Open/Swoole Symfony Bundle

6650.4k](/packages/swoole-bundle-swoole-bundle)

PHPackages © 2026

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