PHP code example of lsr / inertia

1. Go to this page and download the library: Download lsr/inertia library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lsr / inertia example snippets


use Lsr\Inertia\Middleware\InertiaMiddleware;
use Lsr\Inertia\Services\Inertia;
use Psr\Http\Message\ServerRequestInterface;

/** @var ServerRequestInterface $request */
$inertia = $request->getAttribute(InertiaMiddleware::INERTIA_ATTRIBUTE);
if (!$inertia instanceof Inertia) {
    throw new LogicException('Inertia middleware must run before this handler.');
}

return $inertia->render('Welcome', ['message' => 'Hello from PHP']);