Skip to main content

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 traditional routes/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.
composer require laravel/folio
php artisan folio:install
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.
use Laravel\Folio\Folio;

Folio::path(resource_path('views/pages/guest'))->uri('/');

Folio::path(resource_path('views/pages/admin'))
    ->uri('/admin');

Creating routes

Folio automatically generates URLs from Blade file names under mounted directories.
resources/views/pages/schedule.blade.php -> /schedule
php artisan folio:list

Nested routes

If you nest directories, URLs follow the same nested structure.
php artisan folio:page user/profile
# pages/user/profile.blade.php -> /user/profile

Index routes

index.blade.php maps to the root of its directory.
php artisan folio:page index
# pages/index.blade.php -> /

php artisan folio:page users/index
# pages/users/index.blade.php -> /users

Route parameters

Use [] in file names to capture URL segments.
php artisan folio:page "users/[id]"
# pages/users/[id].blade.php -> /users/1
<div>User {{ $id }}</div>
Use ... when you need to capture multiple segments.
php artisan folio:page "users/[...ids]"
# pages/users/[...ids].blade.php -> /users/1/2/3
@foreach ($ids as $id)
    <li>User {{ $id }}</li>
@endforeach

Route model binding

If you use a model name like [User].blade.php, the model is resolved automatically.
php artisan folio:page "users/[User]"
# pages/users/[User].blade.php -> /users/1
<div>User {{ $user->id }}</div>
If you also need to handle soft-deleted models, call withTrashed() inside the page.
<?php

use function Laravel\Folio\withTrashed;

withTrashed();
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, use middleware() in the page template.
<?php

use function Laravel\Folio\middleware;

middleware(['auth', 'verified']);
To apply middleware to multiple pages at once, use Folio::path(...)->middleware().
<?php

use Laravel\Folio\Folio;

Folio::path(resource_path('views/pages'))->middleware([
    'admin/*' => ['auth', 'verified'],
]);

Named routes

You can also assign route names to Folio pages with name().
<?php

use function Laravel\Folio\name;

name('users.index');
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]).
You can generate URLs for assigned route names using the route() helper.
route('users.index');
route('users.show', ['user' => $user]);

File-to-URL mapping

Comparison with traditional routing

FeatureStandard routingFolio
Route definitionroutes/web.phpAutomatic from file names
ControllerRequired (or closure)Not required (directly in Blade)
Best use casesAPIs, SPAs, complex HTTP controlContent sites, admin screens
Even when using Folio, enabling route caching with php artisan route:cache helps optimize production performance.
Last modified on April 16, 2026