Lwin Maung Maung

My Notes and Blogs

Home Laravel Linux

Laravel Folio Explained and best use cases

Published on  Aug 2nd, 2023Updated:  Jul 20th, 2024
2 mins Read

Laravel Folio is the newest package announced in LaraconUS. I am interested in it for two reasons. It already works in NextJS and now arrives in Laravel.

We are PHP, and PHP has built-in file routing. In a typical PHP project, we can create index.php, web.php, and profile.php files, which can easily be accessed using the file path. So, why Laravel Folio?

Features of Laravel Folio

The features of Laravel folio are as follows:
1. Nested Routes
2. Index Routes
3. Route Parameters
4. Route Model Binding

Resource Storage Path explained!

The resource files are inside the resource/views/pages. It is very similar to Livewire if you are used to it. So, if you created the folder earlier, it is time to rename the pages folder and refractor it before you use it again. Otherwise, win the lottery.

Nested Routes

It simply can route /user/profile to /user/profile.php. I am not sure that it will work with catch-all pages. However, we can still use routes/web.php and Laravel Folio page-based routing together.

Index Routes

Index routes never leave PHP and web server standards. They are still index.php. /user will route to pages/user/index.php. No other files. I love it.

Route Parameter

If you use page routing in NextJS, it is very close to each other. In Laravel Folio, /pages/user/[id].blade.php will serve /user/1 but will not fit /user/1/2/3. To catch nested routes, use [..ids].blade.php.

Route Model Binding

It is my Favourite. We need to use page routing for static 
pages. I don't want a large code block at the top of the blade file. If I have to, it is a rule break of MVC. It is a huge plus. You can customize the key too. Middle and PHP Blocks work inside @php blocks.


In my opinion, I want to use Laravel Folio for static page serving with backend CMS. Examples include Blog Pages, Announcements and ChangeLog, etc. I love to use both routes/web.php and file routing. It is better suitable for relays for the backend, like headless CMS or documentation storages.

© lwinmaungmaung MMXXIII. All Rights Reserved.