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

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

geerlingguy/request
===================

A simple PHP HTTP request class.

1.x-dev(4y ago)62379251MITPHP

Since Dec 15Pushed 4y ago10 watchersCompare

[ Source](https://github.com/geerlingguy/Request)[ Packagist](https://packagist.org/packages/geerlingguy/request)[ RSS](/packages/geerlingguy-request/feed)WikiDiscussions 1.x Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (1)

[![Request for PHP Logo](https://raw.githubusercontent.com/geerlingguy/Request/1.x/Resources/Request-Logo.png)](https://raw.githubusercontent.com/geerlingguy/Request/1.x/Resources/Request-Logo.png)

Request
=======

[](#request)

A simple PHP HTTP request class.

This class includes many convenience methods to help take the headache out of dealing with HTTP requests in PHP.

Usage
-----

[](#usage)

Include the class (`\JJG\Request`) using an autoloader, then build a new Request object, execute the request, and get the response.

```
$request = new Request('http://www.example.com/');
$request->execute();
$response = $request->getResponse();
```

Other parameters you can retrieve after executing a request include:

```
// The full headers from the response.
$request->getHeader();
// The latency for this response, in ms.
$request->getLatency();
// The HTTP status code (e.g. 200 for 200 OK).
$request->getHttpCode();
// Empty if no error present, otherwise shows any cURL errors.
$request->getError();
```

There are also other convenient methods included for other purposes.

```
// Returns TRUE if 'string' exists in the response.
$request->checkResponseForContent('string');
```

You can also make requests with basic HTTP authentication:

```
// Execute a request with HTTP basic authentication.
$request = new Request('http://www.example.com/secure-page');
$request->setBasicAuthCredentials('username', 'password');
$request->execute();
```

Other options include enabling or disabling SSL, using cookies, and setting cURL timeout values:

```
// Enable Cookies.
$request->enableCookies($cookie_file_path);
// Enable SSL/TLS.
$request->enableSSL();
// Set the user agent string.
$request->userAgent = 'User agent string here.';
// Set the initial connection timeout (default is 10 seconds).
$request->connectTimeout = 5;
// Set the timeout (default is 15 seconds).
$request->timeout = 10;
// Send some fields as a POST request.
$request->setRequestType('POST');
$request->setPostFields($field_array);
```

See the Request class variable definitions and methods for more details and documentation.

Why Request?
------------

[](#why-request)

I've used other HTTP request libraries for PHP before, but often fall back to using cURL directly, because the libraries I've used are too complicated for my needs. This library aims to be a very simple and easy-to-use wrapper around cURL, and should be easy to pick up for anyone familiar with cURL usage in PHP.

Some other recommended HTTP libraries for PHP include:

- [Guzzle](http://guzzlephp.org/)
- [Httpful](http://phphttpclient.com/)
- [Zend\_Http](http://framework.zend.com/manual/1.12/en/zend.http.html)
- [Unirest](https://github.com/mashape/unirest-php)
- [Requests](https://github.com/rmccue/Requests)

License
-------

[](#license)

Request is licensed under the MIT (Expat) license. See included LICENSE.md.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community21

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 Bus Factor1

Top contributor holds 87.5% 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

Unknown

Total

1

Last Release

1658d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/481677?v=4)[Jeff Geerling](/maintainers/geerlingguy)[@geerlingguy](https://github.com/geerlingguy)

---

Top Contributors

[![geerlingguy](https://avatars.githubusercontent.com/u/481677?v=4)](https://github.com/geerlingguy "geerlingguy (14 commits)")[![minecraftchest1](https://avatars.githubusercontent.com/u/42992675?v=4)](https://github.com/minecraftchest1 "minecraftchest1 (1 commits)")[![tinyhill](https://avatars.githubusercontent.com/u/3794620?v=4)](https://github.com/tinyhill "tinyhill (1 commits)")

---

Tags

curllibrarypackagistphprequest

### Embed Badge

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

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

###  Alternatives

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M81](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.2M6.6k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k20.0k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k113](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M85](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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