Download the PHP package cherif/inertia-psr15 without Composer
On this page you can find all versions of the php package cherif/inertia-psr15. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cherif/inertia-psr15
More information about cherif/inertia-psr15
Files in cherif/inertia-psr15
Package inertia-psr15
Short Description InertiaJS server-side adapter for PSR-7 and PSR-15 applications
License BSD-3-Clause
Informations about the package inertia-psr15
inertia-psr15
Before using this library, is important to know what is Inertia.js, what is it for and how it works, in the official Inertia.js website
PHP PSR-15 InertiaJS server-side adapter, it can be used with Mezzio, Slim 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:
Usage:
A small application was made to demonstrate how this adapter can be used in Mezzio application.
The adapter is designed to work with Mezzio with little effort, in the following we assume that a Mezzio application was generated using Mezzio Skeleton and Twig was selected as the template engine:
Installation:
1- Install the adapter:
2- Add the inertia middleware to the middlewares pipeline:
3- Please refer to InertiaJS to install a client-side adapter.
4- Using Webpack is recommended in order to build the front-end application, however, to render the built JS/CSS assets in a Twig template the following extension can be used:
a factory might be needed to configure the Webpack extension
5- Configure the templte to use Webpack extension and the Inertia Twig extension shipped with the adapter
by apdating config/autoload/template.global.php
and webpack.global.php
like the following:
6- The adapter needs just one backend template to render the application and by default it will look for
templates/app.html.twig
if a default template is not configured, the app template can be like the following:
The template uses Webpack extension (webpack_entry_css, webpack_entry_js) to render the assets and Inertia extension
inertia(page)
to mount the front-end application.
After successful configuration the adapter can be used to render the front-end component instead of the HTML templates:
Copyright
Mohammed Cherif BOUCHELAGHEM 2021