PHPackages                             madnh/request - 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. madnh/request

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

madnh/request
=============

cURL wrapper

1.3.0(9y ago)01.4kMITPHPPHP &gt;=5.3.0

Since Dec 28Pushed 9y ago1 watchersCompare

[ Source](https://github.com/madnh/request)[ Packagist](https://packagist.org/packages/madnh/request)[ Docs](https://github.com/madnh/request)[ RSS](/packages/madnh-request/feed)WikiDiscussions master Synced today

READMEChangelog (5)DependenciesVersions (6)Used By (0)

A cURL wrapper

Config
======

[](#config)

Request support 3 ways of config:

- Global config
- Instance's config
- Request's config

Inherit: Global config &lt;- Instance's config &lt;- Request's config

Default config
--------------

[](#default-config)

- url: request's URL
- request\_type: request method, default is *'GET'*
- data: request data, string or array, default is empty string
- use\_cookie: use cookie? default is **true**
- cookie: custom cookie to request, default is **empty array**
- cookie\_send: Path of cookie file, use when send request
- cookie\_save: Path of cookie file, use to store cookie after every request
- fail\_on\_error: stop on error? default is **true**
- follow\_location: follow any redirect? default is **true**
- return\_transfer: return response instead of print it out, default is **true**
- header: request header, array, default is **empty array**
- return\_header: return response's header
- verifying\_ssl: default is **false**
- use\_proxy: default is **false**
- proxy: proxy's info
- is\_http\_proxy: default is **true**
- referer: default is **true**
- timeout: request timout, default is **3600**
- useragent: useragent info of request, default is **'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.130 Safari/537.36'**

Global config
-------------

[](#global-config)

```
Request::globalConfig('cookie_send', __DIR__.'/cookie.txt');
Request::globalConfig('cookie_save', __DIR__.'/cookie.txt');
```

Response
========

[](#response)

- request: request config, array
- header: response's header, string
- response: response, string
- error: False or array of

    - no: cURL's error number
    - message: error message
- start: UNIX timestamp when request start
- end: UNIX timestamp when request complete

Constant
========

[](#constant)

- AUTH\_MODE\_BASIC
- AUTH\_MODE\_DIGEST
- AUTH\_MODE\_GSSNEGOTIATE
- AUTH\_MODE\_NTLM
- AUTH\_MODE\_ANY
- AUTH\_MODE\_ANYSAFE

How to use
==========

[](#how-to-use)

1. Setup global config, if need
2. Create new instance, which config if need
3. Setup instance config
4. Make request, requets may include config if need

Config methods
--------------

[](#config-methods)

- globalConfig(config\_name: string or array of configs, \[value = null\])
- getGlobalConfig()
- getConfig(): export config

Request Methods
---------------

[](#request-methods)

- request(config)
- get(url, \[data, \[config\])
- post(url, \[data, \[config\])
- put(url, \[data, \[config\])
- delete(url, \[data, \[config\])

Other methods
-------------

[](#other-methods)

- setHeader(headers), set request headers, return instance
- addHeader(name, value): add a request header, return instance
- setCookie(cookies), set request cookies, return instance
- addCookie(name, value), set a request cookie value, return instance
- setData(data): set request data, return instance
- addData(name, value): add a request data, return instance
- rawConfig(CURL Options instance, value), set config, return instance
- setBasicAuthentication(username, password), set basic auth info, return instance
- setHttpAuthMode(mode): set auth mode. Return instance. Support:
    - AUTH\_MODE\_BASIC
    - AUTH\_MODE\_DIGEST
    - AUTH\_MODE\_GSSNEGOTIATE
    - AUTH\_MODE\_NTLM
    - AUTH\_MODE\_ANY
    - AUTH\_MODE\_ANYSAFE

Examples
========

[](#examples)

Create new instance

```
$obj = new Request(array(
    'timeout' => 10
));
$result = $obj->request(array(
    'url' => 'http://www.w3schools.com/'
));
print_r($result);
```

Make another request

```
$result = Request::url($_SERVER['HTTP_HOST'] . '/test/target.php')
        ->addData('name', 'Tom')
        ->addData('old', 16)
        ->setCookie(array(
            'is_admin' => true
        ))
        ->ajaxRequest()
        ->post();
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity62

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 ~70 days

Total

5

Last Release

3557d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8559855?v=4)[Đỗ Danh Mạnh](/maintainers/madnh)[@madnh](https://github.com/madnh)

---

Top Contributors

[![madnh](https://avatars.githubusercontent.com/u/8559855?v=4)](https://github.com/madnh "madnh (18 commits)")

---

Tags

requestcurlmadnh

### Embed Badge

![Health badge](/badges/madnh-request/health.svg)

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

###  Alternatives

[aplus/http-client

Aplus Framework HTTP Client Library

2171.6M1](/packages/aplus-http-client)[pear/http_request2

Provides an easy way to perform HTTP requests.

764.3M53](/packages/pear-http-request2)[stefangabos/zebra_curl

A high performance solution for making multiple HTTP requests concurrently, asynchronously from your PHP projects using cURL

21472.0k2](/packages/stefangabos-zebra-curl)[multirequest/multirequest

PHP library for easy and flexible multithread requests handling by CURL.

8331.8k1](/packages/multirequest-multirequest)[pdeans/http

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

1466.3k3](/packages/pdeans-http)[aalfiann/parallel-request-php

A PHP class to create multiple request in parallel (non-blocking).

1219.3k3](/packages/aalfiann-parallel-request-php)

PHPackages © 2026

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