PHPackages                             cherif/inertia-psr15 - 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. cherif/inertia-psr15

ActiveLibrary

cherif/inertia-psr15
====================

InertiaJS server-side adapter for PSR-7 and PSR-15 applications

v0.4.0(1y ago)498.2k↓36.1%6[2 PRs](https://github.com/cherifGsoul/inertia-psr15/pulls)2BSD-3-ClausePHPPHP &gt;=7.4

Since Mar 9Pushed 1y ago2 watchersCompare

[ Source](https://github.com/cherifGsoul/inertia-psr15)[ Packagist](https://packagist.org/packages/cherif/inertia-psr15)[ RSS](/packages/cherif-inertia-psr15/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (7)Versions (8)Used By (2)

inertia-psr15
=============

[](#inertia-psr15)

Before using this library, is important to know [what is Inertia.js](https://inertiajs.com/#top), [what is it for](https://inertiajs.com/who-is-it-for) and [how it works](https://inertiajs.com/how-it-works), in the [official Inertia.js website](https://inertiajs.com/)

PHP PSR-15 [InertiaJS](https://inertiajs.com/) server-side adapter, it can be used with [Mezzio](https://mezzio.dev/), [Slim](https://www.slimframework.com/) or any framework that implements PSR-15 interfaces.

The adapter is a PSR-15 middleware to detect InertiaJS requests and prepare and send Response to be read and rendered by InertiaJS front-end components, the usage after installation and configuration can be easy as:

```
// In some RequestHandlerInterface class

$inertia = $request->getAttribute(InertiaMiddleware::INERTIA_ATTRIBUTE);
return $inertia->render('MyFrontEndComponent', [
    'someProp' => 'someProp Prop Value',
    'ohterProp' => 'ohterProp Prop Value'
]);
```

Usage:
------

[](#usage)

A [small application](https://github.com/cherifGsoul/mezzio-inertia-demo) was made to demonstrate how this adapter can be used in Mezzio application.

The adapter is designed to work with [Mezzio](https://mezzio.dev/) with little effort, in the following we assume that a Mezzio application was generated using [Mezzio Skeleton](https://github.com/mezzio/mezzio-skeleton) and Twig was selected as the template engine:

### Installation:

[](#installation)

1- Install the adapter:

```
composer require cherif/inertia-psr15
```

2- Add the inertia middleware to the middlewares pipeline:

```
