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

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

phpraptor/request
=================

Light weight class to wrap the incoming request in one single object.

v0.1-beta(9y ago)013MITPHPPHP &gt;=5.6.4CI failing

Since Apr 30Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phpraptor/request)[ Packagist](https://packagist.org/packages/phpraptor/request)[ Docs](https://github.com/phpraptor/request)[ RSS](/packages/phpraptor-request/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

[![Build Status](https://camo.githubusercontent.com/88b0cfc36a33962cf1c0fa1ea199ae9a4ea7d14c970ed46c66033f5bbdd40230/68747470733a2f2f7472617669732d63692e6f72672f6d75736874692f726571756573742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mushti/request)[![Code Climate](https://camo.githubusercontent.com/ac5971f94bbbef6db91ec6f14f76f5650c09cd7e845aa5a1e03b6a288f8c7287/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f6d75736874692f726571756573742f6261646765732f6770612e737667)](https://codeclimate.com/github/mushti/request)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d8d23d1c0f5db6ba2b3c51526b033ce808e4bb1d262c67f428fda4fc5b718f63/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d75736874692f726571756573742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mushti/request/?branch=master)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Introduction
============

[](#introduction)

Raptor Request is a light weight PHP library built using the SOLID principles to wrap the incoming HTTP request in one single object, with a structure based on \[[RFC7230](https://tools.ietf.org/html/rfc7230)\].

To install the library , just run the following composer command.

```
composer require phpraptor/request v0.1-beta

```

To capture the request, simply create an object of the `Http` class.

```
use Raptor\Request\Http;

$request = new Http;
```

As stated in [Section 3](https://tools.ietf.org/html/rfc7230#section-3) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\],

> All HTTP/1.1 messages consist of a start-line followed by a sequence of octets in a format similar to the Internet Message Format \[RFC5322\]: zero or more header fields (collectively referred to as the "headers" or the "header section"), an empty line indicating the end of the header section, and an optional message body.
>
> HTTP-message = start-line \*( header-field CRLF ) CRLF \[ message-body \]

Or, in simple words, a request message has three components, a `request-line` (according to [Section 3.1](https://tools.ietf.org/html/rfc7230#section-3.1) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\], for a request message the `start-line` will be a `request-line`), followed by `header-fields` and then a `message-body`.

You can access these three components by calling `line()`, `header()` and `body()` methods on the request object.

```
$request->line();    // request-line
$request->header();  // header fields
$request->body();    // message body
```

Request-line
============

[](#request-line)

[Section 3.1.1](https://tools.ietf.org/html/rfc7230#section-3.1.1) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\] states,

> A request-line begins with a method token, followed by a single space (SP), the request-target, another single space (SP), the protocol version, and ends with CRLF.
>
> request-line = method SP request-target SP HTTP-version CRLF

This means that the request-line itself is further divided into three sub-components.

```
$request->line()->method();   // method token
$request->line()->target();   // request-target
$request->line()->version();  // HTTP-version
```

### Method token

[](#method-token)

To get the method token or the request method, call the `method()` function.

```
$request->line()->method();
$request->method();    // short approach

// Example output:
'POST'
```

### Request-target

[](#request-target)

[Section 5.3](https://tools.ietf.org/html/rfc7230#section-5.3) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\] states,

> There are four distinct formats for the request-target, depending on both the method being requested and whether the request is to a proxy.
>
> request-target = origin-form / absolute-form / authority-form / asterisk-form

According to [Section 3.1.1](https://tools.ietf.org/html/rfc7230#section-5.3.1) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\],

> The most common form of request-target is the origin-form.
>
> origin-form = absolute-path \[ "?" query \]

The `origin-form` has two sub-components, the `absolute-path` and the `query string parameters`.

- #### Absolute-path (Request URI)

    [](#absolute-path-request-uri)

To get the absolute path or the request URI, call the `path()` method.

```
$request->line()->target()->path();

// Example output:
'/company/about'
```

- #### Query String Parameters ($\_GET)

    [](#query-string-parameters-_get)

To get all the query string parameters, call the `query()` method.

```
$request->line()->target()->query();
$request->query();    // short approach

// Example output:
[
    'search' => 'john doe',
    'page' => '2'
]
```

If you want to get a particular query string parameter, call the `query()` method and pass the required key as the argument.

```
$request->line()->target()->query('search');
$request->query('search');    // short approach

// Example output:
'john doe'
```

You can also define a default value to return if a key does not exist in the query string parameters.

```
$request->line()->target()->query('search', 'default value');
$request->query('search', 'default value');    // short approach

// Example output:
'default value'
```

### HTTP-version

[](#http-version)

To get the HTTP-version, call the `version()` method.

```
$request->line()->version();

// Example output:
'HTTP/1.1'
```

Header Fields
=============

[](#header-fields)

To get all the header fields or the request headers, call the `all()` method on the `header()` method of the request object.

```
$request->header()->all();

// Example output:
[
    'HTTP_HOST' => 'localhost',
    'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0',
    'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
    'HTTP_ACCEPT_LANGUAGE' => 'en-US,en;q=0.5',
    'HTTP_ACCEPT_ENCODING' => 'gzip, deflate',
    'HTTP_COOKIE' => 'PHPSESSID=t8ih495a8fap4agrkk9ectn2r5',
    'HTTP_CONNECTION' => 'keep-alive'
]
```

If you want to get a particular header field, call the `get()` method and pass the required key as the argument.

```
$request->header()->get('HTTP_HOST');

// Example output:
'localhost'
```

You can also define a default value to return if a key does not exist in the header fields.

```
$request->header()->get('HTTP_EXAMPLE', 'default value');

// Example output:
'default value'
```

### Cookies ($\_COOKIE)

[](#cookies-_cookie)

The browser cookies are sent to the server with the header fields, so to get all the cookies, call the `cookie()` method on the `header()` method of the request object.

```
$request->header()->cookie();
$request->cookie();    // short approach

// Example output:
[
    'PHPSESSID' => 'lopaavhboml1ua6a539b8u0rm7'
]
```

If you want to get a particular cookie, call the `cookie()` method and pass the required key as the argument.

```
$request->header()->cookie('PHPSESSID');
$request->cookie('PHPSESSID');    // short approach

// Example output:
'lopaavhboml1ua6a539b8u0rm7'
```

You can also define a default value to return if a key does not exist in the cookies.

```
$request->header()->cookie('FONTSIZE', '14px');
$request->cookie('FONTSIZE', '14px');    // short approach

// Example output:
'14px'
```

Message Body
============

[](#message-body)

[Section 3.3](https://tools.ietf.org/html/rfc7230#section-3.3) of the \[[RFC7230](https://tools.ietf.org/html/rfc7230)\] states,

> The message body (if any) of an HTTP message is used to carry the payload body of that request

The payload body can contain request body parameters, i.e. `$_POST`, and any uploaded files, i.e. `$_FILES`.

### Request Body Parameters ($\_POST)

[](#request-body-parameters-_post)

To get all the request body parameters, call the `param()` method.

```
$request->body()->param();
$request->param();    // short approach

// Example output:
[
    'username' => 'phpraptor',
    'password' => 'johndoe'
]
```

If you want get a particular request body parameter, call the `param()` method and pass the required key as the argument.

```
$request->body()->param('username');
$request->param('username');    // short approach

// Example output:
'phpraptor'
```

You can also define a default value to return if a key does not exist in the request body parameters.

```
$request->body()->param('category_id', 30);
$request->param('category_id', 30);    // short approach

// Example output:
30
```

### Uploaded Files ($\_FILE)

[](#uploaded-files-_file)

To get all the uploaded files, call the `files()` method.

```
$request->body()->files();
$request->uploads();    // short approach

// Example output:
[
    'image' => [
        'name' => 'image01.jpg',
        'type' => 'image/jpeg',
        'tmp_name' => '\path\to\tmp\php2660.tmp',
        'error' => 0,
        'size' => 135069
    ]
]
```

If you want get a particular uploaded file, call the `file()` method and pass the required key as the argument.

```
$request->body()->file('image');
$request->file('image');    // short approach

// Example output:
[
    'name' => 'image01.jpg',
    'type' => 'image/jpeg',
    'tmp_name' => '\path\to\tmp\php2660.tmp',
    'error' => 0,
    'size' => 135069
]
```

### Content Length

[](#content-length)

To get the content length of the message body, call the `contentLength()` method.

```
$request->body()->contentLength();

// Example output:
135467
```

### Content Type

[](#content-type)

To get the content type of the message body, call the `contentType()` method.

```
$request->body()->contentType();

// Example output:
'multipart/form-data; boundary=----WebKitFormBoundarySMTxQwbotazq4ctK'
```

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

3349d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/03a068e24f4d188fc27b76d328f0ca5be74a628e46a06f6c8033a36ea8d76c19?d=identicon)[mushti](/maintainers/mushti)

---

Top Contributors

[![mushti](https://avatars.githubusercontent.com/u/19475657?v=4)](https://github.com/mushti "mushti (45 commits)")

---

Tags

http-requestphpphp-libraryraptorraptor-requestrequestrequestphpraptor

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[stefangabos/zebra_curl

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

21672.4k2](/packages/stefangabos-zebra-curl)

PHPackages © 2026

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