Download the PHP package cambis/silverstripe-inertia without Composer
On this page you can find all versions of the php package cambis/silverstripe-inertia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cambis/silverstripe-inertia
More information about cambis/silverstripe-inertia
Files in cambis/silverstripe-inertia
Package silverstripe-inertia
Short Description Inertia.js adapater for Silverstripe.
License MIT
Informations about the package silverstripe-inertia
Inertia.js Silverstripe adapter
Inertia.js adapter for Silverstripe, based on inertia-bundle.
Visit inertiajs.com to learn more.
Getting started
Install the server adapter.
Install the preferred client adapter.
React
Vue
Svelte
Configuration
Here is a basic configuration to get started with.
Server-side
First, configure your Silverstripe application with the following:
Config file
Create a config file:
Template
In your root Page.ss template, add:
The root template location is optionally configurable:
PageController
Configure your PageController class to serve Inertia.
If your IDE supports the @mixin directive, add it to your PageController for autocomplete:
Alternatively, you can use the @property directive:
Client-side
Once your Silverstripe application is setup, you can configure the client application.
React
Vue
Svelte
Lazy data evaluation
Sometimes you don't want to re-evaluate data when making visits to the same page type. This can be accomplised
server-side by using a callback function or lazy().
Check the offical documentation for client side configuration.
Sharing data
You can share props between all components using the $this->inertia->share(string, mixed) function.
One use case is populating the navigation menu for a website, this can be accomplished using a SilverStripe\Core\Extension.
View data
You can pass data to your root Silverstripe template via the render() parameter in the render function:
You can also pass data using the $this->inertia->viewData(string, mixed) function:
Data is accessible using the $ViewData variable
Asset versioning
By default, the middleware checks for the config variables asset_url and manifest_file to get the current asset version.
You can specify your application's asset version by extending the Cambis\Inertia\Control\Middleware\InertiaMiddleware class.
Don't forget to update your configuration if you do this!
Alternatively, you can use the $this->inertia->version(mixed) function to set the current asset version
Cache busting
Check the offical documentation for information on cache busting.
Server-side rendering
To enable server-side rendering, first enable the following config variables ssr_enabled and ssr_host:
Check the official documentation for information on client-side setup.
Demo
You can find a basic demo here
All versions of silverstripe-inertia with dependencies
silverstripe/framework Version ^4.0 || ^5.0
php Version ^7.4 || ^8.0