Topics Packages & Ecosystem Folio Page Router
intermediate 14 min read

Folio Page Router

File-based routing with Laravel Folio, route parameters, model binding, and middleware in pages.

Laravel Folio

Folio provides file-based routing. Pages live in resources/views/pages.

// Install: composer require laravel/folio
// php artisan folio:install

// resources/views/pages/index.blade.php -> /
// resources/views/pages/about.blade.php -> /about

{{-- resources/views/pages/index.blade.php --}}
<x-layout>
<h1>Welcome to {{ config("app.name") }}</h1>
</x-layout>

Route Parameters

// resources/views/pages/users/[id].blade.php -> /users/{id}
<h1>User #{{ $id }}</h1>

// resources/views/pages/posts/[Post].blade.php -> /posts/{post}
{{-- Auto-model binding --}}
<h1>{{ $post->title }}</h1>
<article>{{ $post->body }}</article>

// Multiple parameters
// resources/views/pages/users/[user]/posts/[post].blade.php

Middleware & Route Configuration

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

Laravel 13 Folio

Laravel 13 Folio supports cacheable routes via php artisan folio:cache, improved model binding, and nested directory support.

Examples

<?php
// resources/views/pages/hello/[name].blade.php
// <h1>Hello, {{ \$name }}!</h1>
// <p>Folio matches /hello/alice and passes 'alice' as \$name.</p>

Your Notes

Sign in to take notes for this lesson.

Quiz

Packages & Ecosystem Quiz

0 questions

Sign in to take quiz

Discussion

Sign in to join the discussion.

Flashcards

Sign in to create flashcards.