PHPackages                             comodojo/httprequest - 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. comodojo/httprequest

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

comodojo/httprequest
====================

HTTP request library

1.3.0(7y ago)231.7k22MITPHPPHP &gt;=5.3.0CI failing

Since Jul 22Pushed 4y ago3 watchersCompare

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

READMEChangelog (5)Dependencies (4)Versions (7)Used By (2)

comodojo/httprequest
--------------------

[](#comodojohttprequest)

[![Build Status](https://camo.githubusercontent.com/745519dc3b2429a30705217d696965f8c9f6a4e1f6d8e8c4fe2737e2c957f2ce/68747470733a2f2f6170692e7472617669732d63692e6f72672f636f6d6f646f6a6f2f68747470726571756573742e706e67)](http://travis-ci.org/comodojo/httprequest) [![Latest Stable Version](https://camo.githubusercontent.com/3dabfa3190e38d1959182a8ccf6aacd194fa38dc10baceafb171ce0555a620ee/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f68747470726571756573742f762f737461626c65)](https://packagist.org/packages/comodojo/httprequest) [![Total Downloads](https://camo.githubusercontent.com/b5ebc6c57d7ef04302954a4adfdcf685890f547f28065d009a780246b86c2434/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f68747470726571756573742f646f776e6c6f616473)](https://packagist.org/packages/comodojo/httprequest) [![Latest Unstable Version](https://camo.githubusercontent.com/1541f4c203ba881d26fd6f114736e4ae2fc86d722c72bdf1dcdeb33f8757f614/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f68747470726571756573742f762f756e737461626c65)](https://packagist.org/packages/comodojo/httprequest) [![License](https://camo.githubusercontent.com/d8015ec323c86033d44422f32b650ef71aa2c19ca2a34b7f7ae8253868cd5b0a/68747470733a2f2f706f7365722e707567782e6f72672f636f6d6f646f6a6f2f68747470726571756573742f6c6963656e7365)](https://packagist.org/packages/comodojo/httprequest) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/b7887ec05022f7483bca29ca20caa5899ecd45ef4904daf71804b1284ed76374/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6d6f646f6a6f2f68747470726571756573742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/comodojo/httprequest/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a792f1ef175503bcded2955a8f8fd351e88ed438852d8258be09173de61214ce/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f636f6d6f646f6a6f2f68747470726571756573742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/comodojo/httprequest/?branch=master)

HTTP request library

***This is the development branch, please do not use it in production***

Main features:

- BASIC, NTLM, DIGEST and SPNEGO auth (requires [php curl library](http://php.net/manual/en/book.curl.php)) authentication support
- proxy support
- allowed http methods: GET, POST, PUT, DELETE
- CURL or stream working mode
- request customization (useragent, http version, content type, ...)

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

[](#installation)

Install [composer](https://getcomposer.org/), then:

`composer require comodojo/httprequest`

Basic usage
-----------

[](#basic-usage)

Library usage is trivial: first create an instance of Httprequest specifing remote host address, then use `get` or `send` method to start request. It's important to wrap code in a try/catch block to handle exceptions (if any).

Constructor accepts two parameters: remote host address (required) and a boolean value (optional) that, if false, will force lib to use streams instead of curl.

- Using get:

    ```
    try {

        // create an instance of Httprequest
        $http = new \Comodojo\Httprequest\Httprequest("www.example.com");

        // or:
        // $http = new \Comodojo\Httprequest\Httprequest();
        // $http->setHost("www.example.com");

        // get remote data
        $result = $http->get();

    } catch (\Comodojo\Exception\HttpException $he) {

    	/* handle http specific exception */

    } catch (\Exception $e) {

    	/* handle generic exception */

    }
    ```
- Using send:

    ```
    $data = array('foo'=>'bar', 'baz'=>'boom');

    try {

        // create an instance of Httprequest
        $http = new \Comodojo\Httprequest\Httprequest("www.example.com");

        // get remote data
        $result = $http->setHttpMethod("POST")->send($data);

    } catch (\Comodojo\Exception\HttpException $he) {

    	/* handle http specific exception */

    } catch (\Exception $e) {

    	/* handle generic exception */

    }
    ```

Class setters (chainable methods)
---------------------------------

[](#class-setters-chainable-methods)

- Set destination port (default 80)

    ```
    $http->setPort(8080);
    ```
- Set timeout (in secs)

    ```
    $http->setTimeout(10);
    ```
- Set a custom user agent (default to 'Comodojo-Httprequest')

    ```
    $http->setUserAgent("My-Custom-User-Agent");
    ```
- Set HTTP version (1.0 or 1.1)

    ```
    $http->setHttpVersion("1.1");
    ```
- Set content type (default to 'application/x-www-form-urlencoded' and used only with `send` method)

    ```
    $http->setContentType("multipart/form-data");
    ```
- Set additional/custom headers:

    ```
    $http->setHeader("My-Header","foo");
    ```
- Set authentication:

    ```
    // NTLM
    $http->setAuth("NTLM", "myusername", "mypassword");

    // BASIC
    $http->setAuth("BASIC", "myusername", "mypassword");
    ```
- Set proxy:

    ```
    // No authentication
    $http->setProxy(proxy.example.org);

    // Authentication
    $http->setProxy(proxy.example.org, "myusername", "mypassword");
    ```
- Ignore errors (stream only):

    Force the stream to ignore errors and to return http code and content from the server instead of throwing an exception.

    ```
    // Set the stream to ignore errors
    $http->setIgnoreErrors(true);
    ```

Class getters
-------------

[](#class-getters)

- Get response headers:

    ```
    // After a request...

    $headers = $http->getReceivedHeaders();
    ```
- Get HTTP received status code:

    ```
    // After a request...

    $code = $http->getHttpStatusCode();
    ```

Multiple requests
-----------------

[](#multiple-requests)

The `reset` method helps resetting options and data channel; for example:

```
try {

    // create an instance of Httprequest
    $http = new \Comodojo\Httprequest\Httprequest();

    // first request
    $first_data = $http->setHost("www.example.com")->get();

    // channel reset
    $http->reset();

    // second request
    $second_data = $http->setHost("www.example2.com")->setHttpMethod("POST")->send(array("my"=>"data"));

} catch (\Comodojo\Exception\HttpException $he) {

	/* handle http specific exception */

} catch (\Exception $e) {

	/* handle generic exception */

}
```

Documentation
-------------

[](#documentation)

- [API](https://api.comodojo.org/libs/Comodojo/Httprequest.html)

Contributing
------------

[](#contributing)

Contributions are welcome and will be fully credited. Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

License
-------

[](#license)

`comodojo/httprequest` is released under the MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 69.2% 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 ~319 days

Recently: every ~355 days

Total

6

Last Release

2720d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cc933c2d1b92f7fd32abb459387bff69fc8a87158b1474171ccf26139904706?d=identicon)[comodojo](/maintainers/comodojo)

---

Top Contributors

[![marcogiovinazzi](https://avatars.githubusercontent.com/u/12754673?v=4)](https://github.com/marcogiovinazzi "marcogiovinazzi (9 commits)")[![tljennings](https://avatars.githubusercontent.com/u/32520145?v=4)](https://github.com/tljennings "tljennings (3 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

httprequestproxybasiccomodojoNTLM

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/comodojo-httprequest/health.svg)

```
[![Health](https://phpackages.com/badges/comodojo-httprequest/health.svg)](https://phpackages.com/packages/comodojo-httprequest)
```

###  Alternatives

[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

7.9k1.0B3.2k](/packages/guzzlehttp-psr7)[psr/http-message

Common interface for HTTP messages

7.1k1.0B5.5k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k692.9M1.9k](/packages/psr-http-factory)[nette/http

🌐 Nette Http: abstraction for HTTP request, response and session. Provides careful data sanitization and utility for URL and cookies manipulation.

48819.2M541](/packages/nette-http)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39489.0M274](/packages/fig-http-message-util)[psr/http-server-handler

Common interface for HTTP server-side request handler

177101.3M921](/packages/psr-http-server-handler)

PHPackages © 2026

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