Skip to main content

Introduction

Laravel Folio is a page-based router that lets you define routes just by placing Blade files. Unlike the traditional routes/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.
To capture multiple segments, use ....

Route model binding

If you use a model name like [User].blade.php, the model is resolved automatically.
To also handle soft-deleted models, call 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, use middleware() inside the page template.
To apply middleware to multiple pages at once, use Folio::path(...)->middleware().

Named routes

You can name a Folio page with name() 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]).
You can generate URLs with the assigned route name using the route() helper.

Mapping between files and URLs

Comparison with traditional routing

Even when using Folio, enabling the route cache with php artisan route:cache optimizes production performance.
Last modified on July 13, 2026