Laravel Folio is a new page-based routing system introduced by the Laravel team. Its main advantage is simplifying the process of defining routes by following a file-system-based approach—similar to frameworks like Next.js, Nuxt, or Remix.
Key advantages of Laravel Folio:
-
Simplicity and Convention
With Folio, you don’t need to manually define routes for each page inweb.phporapi.php. Instead, the routes are automatically generated based on the structure of your files in theresources/views/pagesdirectory. The file path determines the route, reducing boilerplate configuration.Example:
resources/views/pages/about.blade.php => /about resources/views/pages/blog/post/[slug].blade.php => /blog/post/{slug} -
Rapid Prototyping
Folio is especially helpful for quickly prototyping applications or building sites where most routes simply return a corresponding view. -
Less Boilerplate
You don't need to write controller methods or route definitions for every page. If a page doesn’t need specific logic, it can just be a Blade file. -
Dynamic Parameters
Folio supports dynamic route parameters and even route model binding via file naming conventions.Example:
resources/views/pages/posts/[post].blade.php => /posts/{post} -
Clear Project Structure
The file-based routing encourages clarity and organization in your view files, mirroring your actual URL structure. -
Built-in Layouts and Shared Data
Folio supports automatic layout assignment and lets you share data across pages using Blade components or context files.
When should you use Folio?
- If your app is primarily page-based (e.g., simple marketing sites, blogs, or documentation), Folio can speed up development.
- For larger apps with heavy controller logic, you might still want to use traditional controllers for certain routes.
A simple Folio example:
resources/views/pages/
├── home.blade.php // Route: /
├── about.blade.php // Route: /about
└── posts/
└── [post].blade.php // Route: /posts/{post}
No manual route definition is needed—Folio handles it.
Summary:
Laravel Folio offers a simpler mental model for routing in page-driven applications, reduces boilerplate code, makes rapid prototyping easier, and enables clear, conventional organization of your pages. If you prefer explicit route handling and deeply custom controller logic, traditional Laravel routing will still serve you well.
More info:
Check out the official Folio documentation for up-to-date details and advanced usage.