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

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

symplely/http
=============

An simple PSR-7 Request/Response implementation, with Cookie, and Session management/middleware.

1.1.1(4y ago)14181MITPHPPHP &gt;7.0CI failing

Since Oct 17Pushed 4y agoCompare

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

READMEChangelog (7)Dependencies (6)Versions (8)Used By (1)

HTTP
====

[](#http)

[![build](https://github.com/symplely/http/actions/workflows/php.yml/badge.svg)](https://github.com/symplely/http/actions/workflows/php.yml)[![codecov](https://camo.githubusercontent.com/c037f7f41b04f5178e8da51bcf30c2be33e1f8226c05d42da871367856d66d47/68747470733a2f2f636f6465636f762e696f2f67682f73796d706c656c792f687474702f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/symplely/http)[![Codacy Badge](https://camo.githubusercontent.com/1ad1d17c96ad421456ee2ee5576484275e4f06c47cdbf51ad35ded08963690a2/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6531386532313335616261663439663262306664396266386432396335313964)](https://www.codacy.com/app/techno-express/http?utm_source=github.com&utm_medium=referral&utm_content=symplely/http&utm_campaign=Badge_Grade)[![Maintainability](https://camo.githubusercontent.com/59a949b89586914f1dbfd90a4a981a4b79f060a8bc40230713de07a51b1d8736/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f65623663323335333064386339663836346631362f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/symplely/http/maintainability)

An complete [PSR-7](https://www.php-fig.org/psr/psr-7/) *Request*/*Response* implementation, with *Cookie*, and *Session* management/middleware.

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

[](#installation)

It's best to install using [Composer](https://getcomposer.org/).

```
composer require symplely/http

```

Outline
-------

[](#outline)

- [Abstract Messages](#abstract-messages)
- [Requests](#requests)
- [Responses](#responses)
- [File Uploads](#file-uploads)
- [Streams](#streams)
- [URIs](#uris)
- [Cookies](#cookies)
- [Sessions](#sessions)

Abstract Messages
-----------------

[](#abstract-messages)

All `Request` and `Response` classes share a base `MessageAbstract` class that provides methods for interacting with the headers and body of a message.

The following methods are available on all `Request` and `Response` objects:

### `getProtocolVersion()`

[](#getprotocolversion)

Gets the HTTP protocol version as a string (e.g., "1.0" or "1.1").

### `withProtocolVersion($version)`

[](#withprotocolversionversion)

Returns a new instance of the message with the given HTTP protocol version as a string (e.g., "1.0" or "1.1").

### `getHeaders()`

[](#getheaders)

Returns an array of the headers tied to the message. The array keys are the header names and each value is an array of strings for that header.

### `hasHeader($name)`

[](#hasheadername)

Makes a case-insensitive comparison to see if the header name given exists in the headers of the message. Returns `true` if found, `false` if not.

### `getHeader($name)`

[](#getheadername)

Returns an array of strings for the values of the given case-insensitive header. If the header does not exist, it will return an empty array.

### `getHeaderLine($name)`

[](#getheaderlinename)

Returns a comma-separated string of all the values of the given case-insensitive header. If the header does not exist, it will return an empty string.

#### `withHeader($name, $value)`

[](#withheadername-value)

Returns a new instance of the message while replacing the given header with the value or values specified.

```
