PHPackages                             casivaagustin/phrequests - 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. casivaagustin/phrequests

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

casivaagustin/phrequests
========================

Curl Wrapper to make Http request easily

v1.0.1(10y ago)618111MITPHPPHP &gt;=5.3.1

Since Jun 17Pushed 10y ago2 watchersCompare

[ Source](https://github.com/42mate/PHRequests)[ Packagist](https://packagist.org/packages/casivaagustin/phrequests)[ Docs](https://github.com/casivaagustin/PHRequests)[ RSS](/packages/casivaagustin-phrequests/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (3)Used By (1)

PHRequests
==========

[](#phrequests)

PHRequests is an API to make HTTP requests using Curl.

Is pronounced Free-Quests (original Idea by @mgi1982)

Why use PHRequests ?
--------------------

[](#why-use-phrequests-)

- Its built on Curl.
- Simplifies your live by making CURL actually usable.
- Inspired by the Requests API for Python, this pretends to be a port for PHP

Usage
-----

[](#usage)

If you need to make a Request to get the content of some Url using Curl a clasic code will look like this.

```
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
  curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
  curl_setopt($ch, CURLOPT_URL, 'http://www.google.com');

  $result = curl_exec($ch);

  if (curl_errno($ch) > 0) {
    //Handle Error
  }

  curl_close($ch);
```

PHRequests wraps all this awful code to make our lives easier.

In order to make a GET Request you should do this

```
$response = \PHRequests\PHRequests::get('http://www.google.com');
```

Yes, only that. Looks nice, take a look to a POST Request.

To make a POST you can do this

```
$opt = array (
  'param1' => 'Some Value',
  'param2' => 'Some other value',
);

$response = \PHRequests\PHRequests::post('http://www.httpbin.org/post', $opt);
```

and that's all folks!

The Response object will hold the result of the request. Also it has a lot of important data of the request.

- $response-&gt;content : The Content of the Request
- $response-&gt;headers : The Response Headers
- $response-&gt;status\_code : The Response Code

And more.

PHRequests uses the PSR-0 standard for class autoloading so you will need a compatible defined autoload function to start using by itself (versus inside a compatible framework like Symfony). You can find one such a function in the Tests\\bootstrap.php file.

To see more samples, check the tests (until I write more documentation).

Proxy Support
-------------

[](#proxy-support)

If your are behind a proxy you need to define the Url of the proxy in order to make the Request. Here is an example.

```
$options = array(
 'proxy' => array(
    'url' => 'http://prx_name_or_ip:3128'
  ),
);
$response = \PHRequests\PHRequests::options(BASE_GET_URL, $options);
```

If your proxy uses auth, try with this

```
$options = array(
 'proxy' => array(
    'url' => 'http://prx_name_or_ip:3128',
    'auth' => 'username:password',
    'auth_method' => Auth::BASIC //Optional, BASIC By default, NTLM is the second option.
  ),
);

$response = \PHRequests\PHRequests::options(BASE_GET_URL, $options);
```

HTTPS support
-------------

[](#https-support)

In order to make HTTPs Requests against a valid HTTPs Server. You need download and save the Certificate of the site, save it into a reachable folder. After, you need to define the option ssl\_ca with the full path to the certificate in order to setup PHRequest. Here is an example.

```
$options = array (
  'ssl_ca' => '../certs/mycert.pem';
)
$response = PHRequests::get('https://www.mysite.com', $options);
```

If you don't set the PEM certificate, the HTTPs request will be made anyway but without a proper certificate validation, the connection will be still an SSL connection but can be a security issue accept any certificate without validation.

IMPORTANT : The certificate must be a PEM certificate.

Here you have more detailed explanation about HTTPs with curl.

Save Remote Files Locally
-------------------------

[](#save-remote-files-locally)

To get a remote file and save it locally you can do the following.

```
\PHRequests\PHRequests::saveRemoteFile($urlSource, $pathDest, $options);
```

The file located in $urlSource, will be saved in $pathDest, using $options.

The request will be made with GET method.

IMPORTANT : The BAD usage of this feature can create security problems, please keep that in mind and be careful.

Supported methods.
------------------

[](#supported-methods)

- GET
- POST
- PUT
- DELETE
- HEAD
- OPTIONS

Todo
----

[](#todo)

- Session Supports
- Cookies Supports
- Auth Mecanism

How to run the tests
--------------------

[](#how-to-run-the-tests)

First install phpunit, i'm using PHPUnit 4.7.3 and I have installed using the phar file.

Go to the test folder, and just run

```
phpunit .

```

That will run all the tests.

I'm having troubles to write a good public tests to test the proxies functionality, need an open and public proxy to validate that works, that's why that test is disabled.

If you are going to work in the proxy features, please, set a proxy, enable the test and test it before commit.

Support
-------

[](#support)

If you want a special feature or if you find a bug, please, let me know.

If you want to contribute to the project, also, please let me know :).

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.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 ~271 days

Total

2

Last Release

3707d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6ab50ea33a49c18b47881d56de6ee5596f6cb5e5a61ad3eef87540d4c294ec35?d=identicon)[casivaagustin](/maintainers/casivaagustin)

---

Top Contributors

[![casivaagustin](https://avatars.githubusercontent.com/u/95085603?v=4)](https://github.com/casivaagustin "casivaagustin (30 commits)")[![casivaagustin-zz](https://avatars.githubusercontent.com/u/673481?v=4)](https://github.com/casivaagustin-zz "casivaagustin-zz (8 commits)")[![mgi1982](https://avatars.githubusercontent.com/u/530722?v=4)](https://github.com/mgi1982 "mgi1982 (4 commits)")[![ezequielpintos](https://avatars.githubusercontent.com/u/1329230?v=4)](https://github.com/ezequielpintos "ezequielpintos (2 commits)")

---

Tags

httprestcurl

### Embed Badge

![Health badge](/badges/casivaagustin-phrequests/health.svg)

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

###  Alternatives

[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.2M266](/packages/nategood-httpful)[voku/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

16183.9k1](/packages/voku-httpful)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

11259.2k](/packages/e-moe-guzzle6-bundle)[msankhala/parsehub-php

Php wrapper classes for Parsehub REST api.

1312.4k](/packages/msankhala-parsehub-php)

PHPackages © 2026

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