PHPackages                             sirix/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. [API Development](/categories/api)
4. /
5. sirix/inertia-psr15

ActiveLibrary[API Development](/categories/api)

sirix/inertia-psr15
===================

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

1.1.1(8mo ago)016BSD-3-ClausePHPPHP ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0CI passing

Since Aug 30Pushed 8mo agoCompare

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

READMEChangelog (4)Dependencies (8)Versions (5)Used By (0)

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

[](#sirix-inertia-psr15)

This is a maintained fork of . It preserves the original goal while updating PHP versions, tooling, and namespace/package details for this fork. See “Fork notes” below for differences.

Before using this library, it’s 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), on 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. After installation and configuration, usage can be as simple as:

```
// In some RequestHandlerInterface class

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

Fork notes
----------

[](#fork-notes)

- Package name: sirix/inertia-psr15
- PHP versions: ~8.1 to ~8.4 supported
- Namespace: Sirix\\InertiaPsr15\\
- Tooling added: PHP-CS-Fixer, PHPStan, Rector configs and GitHub Actions.
- This README has been adjusted to reflect the fork; code usage remains the same with updated namespaces.

Usage:
------

[](#usage)

A [small application](https://github.com/sirix777/mezzio-inertia-svelte-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 sirix/inertia-psr15
```

2- Add the inertia middleware to the middlewares pipeline:

```
