mercuryseries / inertia-bundle
Enhanced Symfony adapter for Inertia.js.
Installs: 125
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.4|^8.1
- dneustadt/csrf-cookie-bundle: ^1.0
- friendsofsymfony/jsrouting-bundle: ^2.8|^3.2
- rompetomp/inertia-bundle: ^2.4
- symfony/config: ^5.0|^6.0
- symfony/console: ^5.0|^6.0
- symfony/dependency-injection: ^5.0|^6.0
- symfony/form: ^5.0|^6.0
- symfony/http-kernel: ^5.0|^6.0
- symfony/process: ^5.0|^6.0
- symfony/serializer-pack: ^1.2
- symfony/twig-bundle: ^5.0|^6.0
Requires (Dev)
- laravel/pint: ^1.10
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