Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
Laravel Folio is a page-based router that lets you define routes by placing Blade files. Unlike the traditionalroutes/web.php-centered approach, Folio maps your filesystem structure directly to URLs.
It works especially well for content-heavy sites and admin screens where you want to add pages quickly.
For areas that need fine-grained HTTP control, such as APIs, it is practical to combine Folio with standard routing.
Installation
First, add Folio with Composer.folio:install registers Folio’s service provider.
By default, the page directory is resources/views/pages/.
If you want to use multiple page directories or base URIs, configure Folio::path() and uri() in the service provider’s boot method.
Creating routes
Folio automatically generates URLs from Blade file names under mounted directories.Nested routes
If you nest directories, URLs follow the same nested structure.Index routes
index.blade.php maps to the root of its directory.
Route parameters
Use[] in file names to capture URL segments.
... when you need to capture multiple segments.
Route model binding
If you use a model name like[User].blade.php, the model is resolved automatically.
withTrashed() inside the page.
If you write
[Post:slug].blade.php, model binding can use a key other than id (for example, slug).Middleware
To apply middleware to a specific page, usemiddleware() in the page template.
Folio::path(...)->middleware().
Named routes
You can also assign route names to Folio pages withname().
If you define
name('users.show') on a detail page like users/[User].blade.php, you can generate parameterized URLs with route('users.show', ['user' => $user]).route() helper.
File-to-URL mapping
Comparison with traditional routing
| Feature | Standard routing | Folio |
|---|---|---|
| Route definition | routes/web.php | Automatic from file names |
| Controller | Required (or closure) | Not required (directly in Blade) |
| Best use cases | APIs, SPAs, complex HTTP control | Content sites, admin screens |