PHPackages                             webstronauts/unpoly - 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. webstronauts/unpoly

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

webstronauts/unpoly
===================

PHP middleware for handling Javascript Unpoly Framework requests

v3.0.0(7mo ago)362.1k↓50%6[1 issues](https://github.com/webstronauts/php-unpoly/issues)MITPHPPHP ^8.1CI passing

Since Jun 7Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/webstronauts/php-unpoly)[ Packagist](https://packagist.org/packages/webstronauts/unpoly)[ Docs](https://github.com/webstronauts/php-unpoly)[ RSS](/packages/webstronauts-unpoly/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (4)Versions (7)Used By (0)

Unpoly
======

[](#unpoly)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a9f0672c22d8d928cd19a1fde2d1705d7a7cdbece57d437d48da269bead47a10/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7765627374726f6e617574732f756e706f6c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webstronauts/unpoly)[![Build Status](https://camo.githubusercontent.com/8734915af63de707f3ee6fe41aa935c08d9c79c42743ddd139ec0b4ea4c229ea/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7765627374726f6e617574732f7068702d756e706f6c792f746573742e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265)](https://github.com/webstronauts/php-unpoly/actions?query=workflow%3Atest)[![Total Downloads](https://camo.githubusercontent.com/4ac092bc054ee16b9afbedb5387b0b6bea4e6cb601d2f99bcdd29dc81573a74a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7765627374726f6e617574732f756e706f6c792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/webstronauts/unpoly)

PHP middleware for handling [Javascript Unpoly Framework](https://unpoly.com) requests.

---

[![](https://camo.githubusercontent.com/c546f07f42bbd83eb4fd0486b57055734f988210eae9da09cc97d00d914cd3b0/68747470733a2f2f7765627374726f6e617574732e636f6d2f696d616765732f6c6f676f2d636972636c652e7376673f666f6f3d626172)](https://camo.githubusercontent.com/c546f07f42bbd83eb4fd0486b57055734f988210eae9da09cc97d00d914cd3b0/68747470733a2f2f7765627374726f6e617574732e636f6d2f696d616765732f6c6f676f2d636972636c652e7376673f666f6f3d626172) Built by **[The Webstronauts](https://webstronauts.com/?utm_source=php-unpoly&utm_campaign=readme-button&utm_medium=github)**, go-to agency for **challenging ideas** and **ambitious organisations**.

---

Unpoly Protocol Support
-----------------------

[](#unpoly-protocol-support)

This package implements the **Unpoly 3.x protocol**, providing full server-side support for:

- ✅ **Request inspection** - Detect Unpoly requests, read target selectors, layer modes, and context
- ✅ **Layer management** - Accept/dismiss overlays, open new layers, manage layer context
- ✅ **Response manipulation** - Set document title, emit events, override targets
- ✅ **Cache control** - Evict or expire cached responses
- ✅ **Cache revalidation** - Support If-Modified-Since, If-None-Match, ETag, Last-Modified, and 304 responses
- ✅ **Vary header management** - Proper cache partitioning with Vary headers
- ✅ **Validation support** - Detect validation requests and handle field-level validation
- ✅ **Context management** - Read and update layer context data
- ✅ **Location/Method control** - Explicitly set browser location and method after fragment updates

The package is compatible with Unpoly 3.x. See the [official protocol documentation](https://unpoly.com/up.protocol) for details.

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

[](#installation)

You can install the package via [Composer](https://getcomposer.org).

```
composer require webstronauts/unpoly
```

Usage
-----

[](#usage)

You can manually decorate the response with the `Unpoly` object.

```
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Webstronauts\Unpoly\Unpoly;

// ...

$unpoly = new Unpoly();
$unpoly->decorateResponse($request, $response);
```

### Symfony

[](#symfony)

To use the package with Symfony, create an event subscriber that decorates responses:

```
