Download the PHP package webkulwp/inertia without Composer
On this page you can find all versions of the php package webkulwp/inertia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package inertia
webkul/inertia
Inertia.js server-side adapter for PHP — the equivalent of what
inertia-laravel provides on Laravel, for any plain-PHP application.
It is framework-agnostic: everything runs on native PHP. When WordPress is
loaded, its helpers (wp_json_encode, status_header, sanitize_text_field,
wp_head / wp_footer in the default shell, the blog_charset option, …)
are picked up automatically — no configuration needed.
It handles the full Inertia protocol:
- First / standard visit → full HTML document with the page object embedded
in a JSON script tag (
script[data-page="<id>"][type="application/json"], the Inertia v3 convention). - Inertia visit (XHR with
X-Inertia: true) → bare JSON page object, no HTML, so the client swaps props without a page reload. - Stale assets (
X-Inertia-Versionmismatch on GET) →409+X-Inertia-Location, telling the client to do one hard reload to pick up new bundles. - Partial reloads → prop filtering via
X-Inertia-Partial-Data/X-Inertia-Partial-Except, with closure props resolved lazily after filtering so skipped props cost no queries.
Installation
While the package lives inside a project as a path repository, add to the
project's composer.json:
Usage
Plain PHP
WordPress (custom HTML shell)
render() always terminates the request.
Configuration
| Method | Purpose |
|---|---|
set_version( string\|callable $version ) |
Asset version used for the 409 stale-asset handshake. |
set_root_view( callable $renderer ) |
Renderer for the HTML shell on standard visits. Receives ( string $page_json, array $page ) and must output the full document. |
set_app_id( string $id ) |
Container / script id used by the built-in fallback shell (default app). Only relevant when no root view is set. |
set_charset( string $charset ) |
Response charset (default UTF-8). Under WordPress the blog_charset option takes precedence. |
If no root view is configured, a minimal shell is rendered: a JSON script tag
plus an empty <div id="<app id>"> — and, inside WordPress, wp_head() /
wp_footer() / body_class() are included automatically.
Examples
Runnable end-to-end examples live in examples/:
examples/react/— client built with the official@inertiajs/reactadapter (React 18), including SPA links and partial reloads viarouter.reload({ only: [...] }).examples/vanilla-js/— no framework: a ~70 line hand-rolled client showing the raw protocol (boot from the JSON script tag,fetch()visits withX-Inertiaheaders, the 409 hard-reload handshake, partial reloads, back/forward handling).
Each folder is a standalone mini-app: php -S localhost:8000 index.php.