mercuryseries/inertia-bundle

Enhanced Symfony adapter for Inertia.js.

Installs: 125

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 4

Forks: 0

Open Issues: 1

Type:symfony-bundle

0.1.0 2023-06-28 09:40 UTC

This package is auto-updated.

Last update: 2024-12-12 01:52:14 UTC


README

This is an enhanced Inertia.js server-side adapter based on rompetomp/inertia-bundle.

The inspiration and some of the API/code for this Bundle comes from the Laravel Inertia Adapter.

Installation

Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that use Symfony Flex

Open a command console, enter your project directory and execute:

$ composer require mercuryseries/inertia-bundle

Applications that don't use Symfony Flex

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

$ composer require mercuryseries/inertia-bundle

Step 2: Enable the Bundle

Then, enable the bundle by adding it to the list of registered bundles in the config/bundles.php file of your project:

// config/bundles.php

return [
    // ...
    MercurySeries\Bundle\InertiaBundle\MercurySeriesInertiaBundle::class => ['all' => true],
];

Step 3: Choose your stack

Add --ssr to any of the following options to add Server-side Rendering (SSR) support:

# React + Webpack Encore
$ symfony console inertia:install react --bundler=webpack

# React + Vite
$ symfony console inertia:install react --bundler=vite

# Vue + Webpack Encore
$ symfony console inertia:install vue --bundler=webpack

# Vue + Vite
$ symfony console inertia:install vue --bundler=vite

Step 4: Routes Configurations

Add the following route configuration if it's missing:

# config/routes.yaml

controllers:
    resource:
        path: ../src/Controller/
        namespace: App\Controller
    type: attribute
+   defaults:
+       csrf:
+           create: true
+           require:
+               - 'POST'
+               - 'PUT'
+               - 'PATCH'
+               - 'DELETE'

Step 5: Install packages and compile assets

# Install npm and run:
$ npm install

# Start the development server:
$ npm run dev-server

# Start coding into assets/js/pages/ 🎉

Production

# First you need to build both client and server bundles
$ npm run build

# Start/Stop the SSR Server
$ symfony console inertia:start-ssr
$ symfony console inertia:stop-ssr