Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Folio Laravel Package

laravel/folio

Laravel Folio is a powerful page-based router for Laravel applications. It simplifies routing by mapping Blade views to routes automatically, letting you build pages with a clean, file-based structure instead of manual route definitions.

View on GitHub
Deep Wiki
Context7

Laravel Folio is a page-based router for Laravel that turns Blade files in a designated directory into routes, eliminating repetitive route definitions. Instead of registering each URL manually, you create pages/users/[id].blade.php and Folio maps it to /users/{id}, passing parameters directly into your view.

  • File-system routing with dynamic [param] segments
  • Route model binding using [User:id] syntax
  • Middleware, named routes, and route grouping support
  • Inline @php blocks and per-page logic
  • Seamless integration with Laravel's existing router and views
Frequently asked questions about Folio
How does Laravel Folio replace traditional route definitions in Laravel?
Folio replaces manual route definitions in `routes/web.php` by mapping files in your `resources/pages/` directory to routes. For example, `resources/pages/about.blade.php` automatically becomes `/about`. You still use Laravel’s middleware, controllers, and Blade templates, but routing is managed via filesystem conventions or a database table.
Can I use Folio for a CMS or marketing site where content changes frequently?
Yes, Folio is ideal for CMS-like applications. You can store pages in a `folio_pages` database table, allowing non-technical users to edit content via a custom admin panel (e.g., Laravel Nova) or directly in the database. Folio supports dynamic slugs, metadata, and even A/B testing via the `priority` field.
What Laravel versions does Folio support, and how do I install it?
Folio supports Laravel 11–13 and PHP 8.4–8.5. Installation is simple: run `composer require laravel/folio`, then execute `php artisan folio:install`. This generates the `folio_pages` migration, model, and config files. No additional setup is needed for basic usage.
How do I handle middleware (e.g., auth) with Folio routes?
Folio integrates seamlessly with Laravel’s middleware. You can assign middleware to individual pages via the `middleware` column in the `folio_pages` table or globally in `config/folio.php`. For terminable middleware (like auth), use the `terminable` option in the config or override the `terminate` method in your `Page` model.
Can I mix Folio routes with traditional Laravel routes in the same app?
Absolutely. Folio coexists with Laravel’s native routing. For example, you can keep API routes in `routes/api.php` while using Folio for page-based routes in `resources/pages/`. The `route()` helper and `routeIs()` methods work identically for both Folio and traditional routes.
What if I have conflicting routes (e.g., `/posts` vs. `/posts/1`)?
Folio resolves conflicts using Laravel’s route priority system. If two routes match, the one defined later in `routes/web.php` or with a higher `priority` in the `folio_pages` table takes precedence. Use `php artisan folio:list` to debug and visualize your route hierarchy.
How do I create a custom admin panel for managing Folio pages?
Folio provides a `Page` model with relationships for easy integration with admin panels like Laravel Nova or Filament. Extend the model to add custom fields (e.g., `seo_title`, `publish_at`) and create a resource for CRUD operations. Folio’s CLI (`folio:list`, `folio:make`) also helps manage pages programmatically.
Does Folio support multi-domain or subdomain routing?
Yes, Folio supports domain-specific routing. Configure the `domains` array in `config/folio.php` to map subdomains (e.g., `blog.example.com`) to specific page directories. You can also use Laravel’s route middleware to enforce domain-specific logic, like `Route::domain('blog.example.com')->group(...).
How do I optimize Folio for production performance?
Cache routes with `php artisan route:cache` and enable Folio’s static rendering for performance-critical pages. Add an index to the `slug` column in `folio_pages` to speed up dynamic lookups. For high-traffic sites, consider using Folio’s filesystem-based routing to avoid database queries entirely.
Are there alternatives to Folio for file-based routing in Laravel?
Folio is the official Laravel solution, but alternatives include third-party packages like `spatie/laravel-page-routes` or `orchid/platform` (for admin panels). However, Folio stands out for its deep Laravel integration, minimal boilerplate, and support for both database-driven and filesystem-based routing out of the box.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
vento/laravel-airbrake
wfeller/laravel-batch
maco-studios/mage-os-installer
busarm/armie
siberfx/laravel-logger
kfteam1991/dcat-admin
dashed/dashed-laposta
dashed/dashed-ecommerce-montaportal
dashed/dashed-ecommerce-etsy
neohq/string-blade-compiler
log1x/acf-composer
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core
nodisrupt/laravel-agent
sierratecnologia/media-manager