Introduction
Laravel Folio is a page-based router that lets you define routes just by placing Blade files. Unlike the traditionalroutes/web.php-centric approach, it reflects your file system structure directly in your URLs.
It’s especially useful for content-focused sites and admin panels where you want to quickly add pages screen by screen.
For areas that need fine-grained HTTP control like APIs, it’s practical to combine Folio with regular routing.
Installation
First, add Folio via Composer.folio:install registers Folio’s service provider.
By default, resources/views/pages/ is the pages directory.
When using multiple page directories or base URIs, configure them with Folio::path() and uri() in your service provider’s boot method.
Creating routes
Folio automatically generates URLs from the Blade file names under the mounted directory.Nested routes
When you nest directories, the URLs are nested with the same structure.Index routes
index.blade.php is mapped to the root of that directory.
Route parameters
You can capture URL segments using[] in the file name.
....
Route model binding
If you use a model name like[User].blade.php, the model is resolved automatically.
withTrashed() inside the page.
With a file name like
[Post:slug].blade.php, you can resolve models by keys other than id (for example, slug).Middleware
To apply middleware only to a specific page, usemiddleware() inside the page template.
Folio::path(...)->middleware().
Named routes
You can name a Folio page withname() as well.
If you define
name('users.show') on a page like users/[User].blade.php, you can generate parameterized URLs with route('users.show', ['user' => $user]).route() helper.