Set up Laravel with Inertia

Search for a command to run...

No comments yet. Be the first to comment.
Our attempt to build a CMS using Laravel and Twill for the back-end and Inertia with Vite, Vue 3 Composition API, TypeScript and Tailwind for the front-end.
Updated version for Laravel 10 / Twill 3 on Apr 14, 2023 Front-end tools installation Laravel comes with a default package.json file to build the front-end assets and already integrates Vite and the Laravel Vite packages. We can now install all the ...
Now that we have set up all the tools to create blocks on both Twill and Vue sides, let's create some generic blocks. Each block will be created in the Common namespace and will be manually added as an allowed block in the controller of our PageConte...

Now that we can create pages, it's time to leverage Twill's powerful content management features and construct reusable blocks. In this article, we will focus on creating a basic Title Twill Block (with a translatable Twill Text Input in a Common nam...

You are probably already familiar with the work of Spatie and its contributors in the Laravel and Open Source ecosystem. For many years, we have been using their Backup package (https://spatie.be/docs/laravel-backup) to back up our applications (data...

If a Twill module uses Revisions, you can benefit from an awesome Twill feature: preview your changes before publishing and compare old revisions. By default, it uses Blade views, so working with Inertia needs some adjustments. The principle For now,...

In this article, we will see the creation and customization of a Twill singleton module to provide a Homepage for our application. Singleton module creation In Twill terminology, a Singleton Module is globally like a classic module except that it man...

Updated version for Laravel 10 / Twill 3 on Apr 13, 2023
If you've never worked on a Laravel project, you can find all the ways to install it and start a new project on the official documentation, and there are many good tutorials you can find depending on your development environment.
Here we work with Docker containers and use Composer to install Laravel in our project folder.
composer create-project laravel/laravel app
That will create the base structure of the project, install all the dependencies and set the default configuration (we generally make a first Git commit after the fresh install).
Inertia comes as a Laravel package that can be installed via Composer. You can refer to the official setup on the official documentation.
composer require inertiajs/inertia-laravel
To have Inertia intercept the application requests and do its magic (shared data, assets versioning), we need to add a middleware.
This can be done by executing an artisan command which will publish the HandleInertiaRequests middleware in our middleware folder /app/HTTP/Middleware.
php artisan inertia:middleware
Once created, we need to register it manually in our /app/Http/Kernel.php file, in the last position of our web route middleware groups.
/**
* The application's route middleware groups.
*
* @var array
*/
protected $middlewareGroups = [
'web' => [
// ...
\App\Http\Middleware\HandleInertiaRequests::class,
],
];
Of course, we need more steps to see Inertia in action, but we now have it ready to handle our application requests.
We'll do our best to provide source code of the serie on GitHub