PHPackages                             dejan7/httpquest - 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. dejan7/httpquest

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

dejan7/httpquest
================

PHP polyfill for HTTP request parsing

0.3.0(9y ago)62481PHPPHP &gt;=5.6.0

Since Sep 12Pushed 9y ago1 watchersCompare

[ Source](https://github.com/dejan7/HTTPQuest)[ Packagist](https://packagist.org/packages/dejan7/httpquest)[ RSS](/packages/dejan7-httpquest/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (4)Used By (1)

[![Build Status](https://camo.githubusercontent.com/5e59216722cabcbe43321943b5e02d50a7fc62c19274133c75fce0052ed3f5e9/68747470733a2f2f7472617669732d63692e6f72672f64656a616e372f4854545051756573742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/dejan7/HTTPQuest) [![Coverage Status](https://camo.githubusercontent.com/054422c879ca45e279d26951fd71e881472d094240bbd8a4326e87e5da78afb6/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f64656a616e372f4854545051756573742f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/dejan7/HTTPQuest?branch=master)

HTTPQuest
=========

[](#httpquest)

HTTPQuest is a lightweight PHP polyfill that can parse incoming request body for any HTTP verb.

\##The problem: PHP by default parses request data only for GET and POST requests and puts them in well-known `$_GET` and `$_POST` and `$_FILES` variables. Additionally it does so only for `multipart/form-data` and `application/x-www-form-urlencoded` enctypes (Content-type HTTP header).

So if you are trying to build a REST API in plain PHP (without a framework) which utilizes other HTTP verbs like PUT or PATCH - it turns out to be a pain. This package attempts to solve that by doing the boring parsing for you and making the request data available for any type of request as well.

\##How to install? `composer require dejan7/httpquest:0.3.0`

\##How to use? Instantiate the class and call the `decode` method somewhere near the beginning of your app (e.g. during bootstrapping).

```
$HTTPQuest = new \HTTPQuest\HTTPQuest();
$HTTPQuest->decode($_POST, $_FILES);

```

And that's all, your parsed data will now be in variables that you passed to the `decode` method (`$_POST`, and `$_FILES` in this case).

PHP puts stuff in `$_POST` and `$_FILES` by default for following cases:

- **POST** : Content-types:
    - `application/x-www-form-urlencoded`
    - `multipart/form-data`

HTTPQuest enhances this and you can configure it to parse data for any method/content-type combination. The default options are set to this:

- **POST**: Content-types:
    - `application/json`
- **PUT**: Content-types:
    - `application/x-www-form-urlencoded`
    - `multipart/form-data`
    - `application/json`
- **PATCH**: Content-types:
    - `application/x-www-form-urlencoded`
    - `multipart/form-data`
    - `application/json`

However, you can change the defaults by passing a `HTTPQuestOptions` instance to the constructor like this:

```
include __DIR__ . "/../vendor/autoload.php";

use HTTPQuest\HTTPQuestOptions;
use HTTPQuest\Requests;
use HTTPQuest\ContentTypes;

$opts = new HTTPQuestOptions();

$opts->forMethod(Requests::GET)
    ->parse(ContentTypes::X_WWW_FORM_URLENCODED);

$opts->forMethod(Requests::PATCH)
    ->parse(ContentTypes::FORMDATA)
    ->parse(ContentTypes::JSON);

$HTTPQuest = new \HTTPQuest\HTTPQuest(
    $_SERVER,
    "php://input",
    $opts
);

```

**Wait! Are you telling me that it can parse request body even for GET requests?**That's correct. Now whether you will utilize such scenarios - i leave the choice to you. You can read some of the discussions on StackOverflow and decide for yourself

\##Files HTTPQuest also parses the files from incoming requests and tries it's best to mimic PHP's default behavior with `$_FILES`. However, the only caveat is that you can't use `move_uploaded_file` PHP function on requests other than POST. On other requests `move_uploaded_file` thinks that the file wasn't uploaded with PHP and it doesn't execute. The workaround is to use `copy` like this:

```
$HTTPQuest = new \HTTPQuest\HTTPQuest();
$HTTPQuest->decode($_POST, $_FILES);

copy($_FILES["myfile"]["tmp_name"], "/some/dir" . $_FILES["myfile"]["name"]);

```

\##Credits [Russel](https://github.com/sndsgd) for [sndsgd/http](https://github.com/sndsgd/http), HTTPQuest uses his multipart/form-data decoding logic.

\##License This is an open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity50

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

Every ~3 days

Total

3

Last Release

3570d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.3.0

0.3.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/6208610?v=4)[Dejan Stosic](/maintainers/dejan7)[@dejan7](https://github.com/dejan7)

---

Top Contributors

[![dejan7](https://avatars.githubusercontent.com/u/6208610?v=4)](https://github.com/dejan7 "dejan7 (23 commits)")

---

Tags

httprequestrestputpatch

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dejan7-httpquest/health.svg)

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

###  Alternatives

[aplus/http

Aplus Framework HTTP Library

2371.6M10](/packages/aplus-http)[elementaryframework/water-pipe

URL routing framework and requests/responses handler for PHP

254.9k4](/packages/elementaryframework-water-pipe)[emartech/escher

Library for HTTP request signing (PHP implementation)

18303.5k9](/packages/emartech-escher)

PHPackages © 2026

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