PHPackages                             phpnomad/http - 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. phpnomad/http

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

phpnomad/http
=============

Foundational components for working with HTTP request/responses.

1.1.1(3w ago)05.2k↓17.1%[3 PRs](https://github.com/phpnomad/http/pulls)7MITPHPCI passing

Since Dec 21Pushed 3w ago2 watchersCompare

[ Source](https://github.com/phpnomad/http)[ Packagist](https://packagist.org/packages/phpnomad/http)[ Docs](https://github.com/phpnomad/core)[ RSS](/packages/phpnomad-http/feed)WikiDiscussions main Synced yesterday

READMEChangelog (5)Dependencies (6)Versions (9)Used By (7)

phpnomad/http
=============

[](#phpnomadhttp)

[![Latest Version](https://camo.githubusercontent.com/cb62c63a0f9e173590c91a08f0ca95324761c348bdf96fe061de500327410a4f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068706e6f6d61642f687474702e737667)](https://packagist.org/packages/phpnomad/http)[![Total Downloads](https://camo.githubusercontent.com/9b5f1c3b1a5ff394bc38230526ba3198f7e7f58cf2cff05dc88d936152bbfafe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068706e6f6d61642f687474702e737667)](https://packagist.org/packages/phpnomad/http)[![PHP Version](https://camo.githubusercontent.com/b616a1fe1baf07fdd9f1c472e8723ef6420b727a4d6445d14ca77a5a49e92e83/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068706e6f6d61642f687474702e737667)](https://packagist.org/packages/phpnomad/http)[![License](https://camo.githubusercontent.com/3faffe12e75a48889b52db02d7dfaf7325cb0a6bb19387f486a4d7fa2a021199/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068706e6f6d61642f687474702e737667)](https://packagist.org/packages/phpnomad/http)

`phpnomad/http` defines the interfaces and enum that describe an HTTP request and response as data. It is not an HTTP client and it is not an HTTP server. It is the contract layer both of those roles build on, so the same `Request` and `Response` types flow through every PHPNomad package that touches HTTP.

Outbound HTTP lives in `phpnomad/fetch`, which returns a `Response` implementation after making a call. Inbound HTTP lives in `phpnomad/rest`, which hands a `Request` to a controller and expects a `Response` back. Concrete implementations come from host integrations such as the WordPress integration, the FastRoute integration, or the Guzzle integration. Because every stack agrees on the same contracts, controllers and client calls written against `phpnomad/http` move between runtimes without rewrites. This package is used by Siren in production and sits underneath most of the PHPNomad framework's HTTP-facing code.

Installation
------------

[](#installation)

```
composer require phpnomad/http
```

Quick Start
-----------

[](#quick-start)

A typical consumer is a REST controller that reads parameters off a `Request` and builds a `Response` with the fluent setters. The controller declares its HTTP verb with the `Method` enum, and the actual `Request` and `Response` instances are supplied by whichever integration package is handling inbound traffic.

```
