Kritim Yantra
Jul 04, 2025
Imagine you're working late, trying to add yet another route for your admin dashboard. It feels repetitive. You're writing boilerplate code just to show a Blade view. What if Laravel could do that for youโautomatically?
That's exactly what Laravel Folio in version 12 brings to the table: a page-based routing system that removes the need for manually defining routes. It's like having Laravel "watch" your folders and auto-magically create the routes you need.
If you're managing an admin panel, Folio can speed up your development process, reduce clutter, and make everything easier to maintain. Letโs dive into how you can implement it in your Laravel backend admin panel, even if you're just starting out.
In simple terms, Folio lets you define routes using file names instead of code.
Create a Blade file like users.blade.php
, and boom! Laravel now serves it at /users
โ no need to touch web.php
or create a controller.
It's heavily inspired by modern frameworks like Next.js and Nuxt.
Open your terminal and run:
composer require laravel/folio
php artisan folio:install
This sets up a new folder: resources/views/pages
. Any Blade files you put here will be served as pages.
You don't want admin pages mixed with your public ones. Let's isolate them.
Create a new folder:
mkdir resources/views/pages/admin
Now update routes/folio.php
(automatically created during installation):
use Laravel\Folio\Folio;
Folio::path(resource_path('views/pages/admin'))
->uri('/admin')
->middleware(['auth', 'admin']);
What this does:
pages/admin
will be served at /admin/...
auth
and admin
middleware.Create a file:
resources/views/pages/admin/dashboard.blade.php
Inside the file:
<x-layout>
<h1>Welcome to the Admin Dashboard</h1>
</x-layout>
Visit /admin/dashboard
in your browser. Done! You just created a route and a page without writing a controller or defining anything in web.php
.
Letโs say you want to show user details at /admin/users/{id}
.
Create a file:
resources/views/pages/admin/users/[id].blade.php
Add logic:
<?php
use App\Models\User;
use function Laravel\Folio\render;
render(function ($view, $id) {
return $view->with('user', User::findOrFail($id));
});
?>
<x-layout>
<h2>User: {{ $user->name }}</h2>
</x-layout>
Laravel will automatically bind {id}
to your route and fetch the correct user.
web.php
.Want an admin page for viewing products? Create:
resources/views/pages/admin/products/index.blade.php
<?php
use App\Models\Product;
use function Laravel\Folio\render;
render(function ($view) {
return $view->with('products', Product::all());
});
?>
<x-layout>
<h1>All Products</h1>
<ul>
@foreach($products as $product)
<li>{{ $product->name }} - ${{ $product->price }}</li>
@endforeach
</ul>
</x-layout>
Done! Product list page, no controller needed.
Laravel 12 Folio isn't just a shiny new toolโit's a game-changer for developers who want to build fast, clean, and secure admin panels with less code.
By using a page-based approach, you keep your routes organized, your middleware scoped, and your brain happy.
So go ahead:
admin/
pagesDrop your thoughts in the comments or share this post with your Laravel buddies ๐งก
No comments yet. Be the first to comment!
Please log in to post a comment:
Sign in with Google