PHPackages                             polymorphine/headers - 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. polymorphine/headers

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

polymorphine/headers
====================

HTTP Response headers middleware

0.1.5(1y ago)0191↓95%1MITPHPPHP ^7.4 || ^8.0

Since Mar 7Pushed 1y ago1 watchersCompare

[ Source](https://github.com/polymorphine/headers)[ Packagist](https://packagist.org/packages/polymorphine/headers)[ RSS](/packages/polymorphine-headers/feed)WikiDiscussions develop Synced 4w ago

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

Polymorphine/Headers
====================

[](#polymorphineheaders)

[![Latest stable release](https://camo.githubusercontent.com/e1ba432799fd5ef2db7e1e2ff4e4b078c39e55edd06924f4098dd93d2d171869/68747470733a2f2f706f7365722e707567782e6f72672f706f6c796d6f727068696e652f686561646572732f76657273696f6e)](https://packagist.org/packages/polymorphine/headers)[![Build status](https://github.com/polymorphine/headers/workflows/build/badge.svg)](https://github.com/polymorphine/headers/actions)[![Coverage status](https://camo.githubusercontent.com/ba0276bfd13a2ec3d53d620bf7b3673c78fdea1a94ec2386bc9237530978b0bb/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f706f6c796d6f727068696e652f686561646572732f62616467652e7376673f6272616e63683d646576656c6f70)](https://coveralls.io/github/polymorphine/headers?branch=develop)[![PHP version](https://camo.githubusercontent.com/aeb74d3d1649875253314c765f68ffecf7104652206e7010f5653d0fd7cc3eff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f706f6c796d6f727068696e652f686561646572732e737667)](https://packagist.org/packages/polymorphine/headers)[![LICENSE](https://camo.githubusercontent.com/13cbf3f852f18ed7a55295523c622e091cfb2bc77b844bc9f401811bf0dc0b5d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f706f6c796d6f727068696e652f686561646572732e7376673f636f6c6f723d626c7565)](LICENSE)

### HTTP Response headers middleware

[](#http-response-headers-middleware)

### Installation with [Composer](https://getcomposer.org/)

[](#installation-with-composer)

```
composer require polymorphine/headers
```

### Basic usage

[](#basic-usage)

##### *Set-Cookie header*

[](#set-cookie-header)

1. Instantiate a cookie builder using `ResponseHeaders` context: ```
    $headers     = new ResponseHeaders();
    $cookieSetup = new CookieSetup($headers);
    ```

    Alternatively, instantiating `CookieSetup` is possible with `ResponseHeaders` method: ```
    $cookieSetup = $context->cookieSetup();
    ```
2. Configure cookie with array of its directives/attributes (see [`CookieSetup::directives()`](/src/Cookie/CookieSetup.php#L51) method): ```
    $cookieSetup->directives([
        'Domain'   => 'example.com',
        'Path'     => '/admin',
        'Expires'  => new DateTime(...),
        'MaxAge'   => 1234,
        'Secure'   => true,
        'HttpOnly' => true,
        'SameSite' => 'Strict'
    ]);
    ```

    Modifying setup object is also possible with its builder methods: ```
    $cookieSetup->domain('example.com')
                ->path('/admin')
                ->expires(new DateTime(...))
                ->maxAge(1234)
                ->secure()
                ->httpOnly()
                ->sameSite('Strict');
    ```
3. Instantiate [`Cookie`](/src/Cookie.php) type object with its name: ```
    $cookie = $cookieSetup->cookie('MyCookie');
    ```
4. Send value: ```
    $cookie->send('value');
    ```

    or order to revoke cookie, so that it should not be sent with future requests: ```
    $cookie->revoke();
    ```

    Each cookie can send/revoke header only once

##### Directives and Attributes

[](#directives-and-attributes)

Directives are used according to [RFC6265](https://tools.ietf.org/html/rfc6265#section-4.1.2)section about Set-Cookie header attributes (except relatively new `SameSite` directive). Their description might also be found at [Mozilla Developer Network](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie). Concise description with additional class logic is explained in docBlocks of mutator methods of [`CookieSetup`](src/Cookie/CookieSetup.php) class.

Here are some class-specific rules for setting those directives:

- Empty values and root path (`/`) might be omitted as they're same as default.
- `SameSite` allowed values are `Strict` or `Lax`, but `Lax` will be set for any non-empty value given.
- `Expires` and `MaxAge` are different ways to set the same cookie's expiry date. If both directives will be passed into constructor or `directivesArray()` method, last value will be used due to overwrite.

##### Cookie with predefined directives

[](#cookie-with-predefined-directives)

`CookieSetup` has two alternative methods creating `Cookie` instance: `CookieSetup::permanentCookie()` and `CookieSetup::sessionCookie()`.

- *Permanent* constructor sets long (5 years) expiry values (`Expires` and `MaxAge`)
- *Session* constructor sets security directives (`HttpOnly` and `SameSite=Lax`)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity53

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 ~284 days

Recently: every ~225 days

Total

6

Last Release

555d ago

PHP version history (2 changes)0.1.0PHP ^7.4

0.1.1PHP ^7.4 || ^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/9908030?v=4)[shudd3r](/maintainers/shudd3r)[@shudd3r](https://github.com/shudd3r)

---

Top Contributors

[![shudd3r](https://avatars.githubusercontent.com/u/9908030?v=4)](https://github.com/shudd3r "shudd3r (55 commits)")

---

Tags

httppsr-15psr-7

### Embed Badge

![Health badge](/badges/polymorphine-headers/health.svg)

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

###  Alternatives

[cakephp/cakephp

The CakePHP framework

8.9k20.0M1.8k](/packages/cakephp-cakephp)[typo3/cms

TYPO3 CMS is a free open source Content Management Framework initially created by Kasper Skaarhoj and licensed under GNU/GPL.

1.2k1.9M122](/packages/typo3-cms)[cakephp/authentication

Authentication plugin for CakePHP

1214.3M114](/packages/cakephp-authentication)[typo3/cms-core

TYPO3 CMS Core

3713.6M5.5k](/packages/typo3-cms-core)[sunrise/http-router

A powerful solution as the foundation of your project.

17451.8k11](/packages/sunrise-http-router)[typo3/cms-adminpanel

TYPO3 CMS Admin Panel - The Admin Panel displays information about your site in the frontend and contains a range of metrics including debug and caching information.

115.8M69](/packages/typo3-cms-adminpanel)

PHPackages © 2026

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