laravel/folio
Laravel Folio is a page-based router for Laravel that lets you define routes by creating files, keeping routing simple and organized. Ideal for building pages quickly with less boilerplate, backed by official Laravel documentation and support.
resources/pages/about.blade.php → /about). This is ideal for content-heavy applications (CMS-like systems, marketing sites, or internal portals) where dynamic pages are managed via a database or filesystem.@route directives and route() helpers).ViewMatched events).routes/web.php. This reduces coupling and simplifies maintenance for content-heavy applications.folio:install Artisan command, which generates:
folio_pages migration/table.Page model (with BelongsTo/HasMany relationships).routes/api.php + Folio routes in resources/pages/). The route() helper and routeIs() methods work identically to Laravel’s defaults.app.example.com/about vs. blog.example.com/posts)./admin/pages and /public/pages).folio_pages table for editable content (e.g., marketing sites)./docs/ → /docs/*).| Risk Area | Assessment | Mitigation Strategy |
|---|---|---|
| Route Conflicts | Overlapping routes (e.g., /posts vs. /posts/1) may cause silent drops or incorrect bindings. |
Use Folio’s priority field in the folio_pages table or leverage Laravel’s route grouping. Test with php artisan folio:list to debug conflicts. |
| Performance | Database queries for dynamic routes may introduce latency if not optimized. | Cache routes with php artisan route:cache and use Folio’s render() method for static pages. Index the slug column in folio_pages. |
| Middleware Complexity | Terminable middleware (e.g., auth) may behave unexpectedly in nested Folio routes. | Test middleware termination with php artisan folio:install --terminable and use Folio’s terminate() method for custom logic. |
| Migration Path | Existing apps with hardcoded routes may require significant refactoring. | Adopt a phased approach: Start with new features (e.g., /blog) using Folio, then migrate legacy routes incrementally. Use route middleware to redirect old paths to new Folio routes. |
| Blade Directive Issues | Custom Blade directives (e.g., @route) may conflict with existing directives. |
Namespace directives with Folio::directive() or use Folio’s built-in @route syntax. |
| PHP/Laravel Version Lock-in | Folio’s support for Laravel 11–13 and PHP 8.4–8.5 may limit flexibility if upgrading. | Monitor Laravel’s release schedule and Folio’s changelog. Use dependency management tools (e.g., laravel-shift/upgrade) to stay updated. |
Content Management Strategy:
folio:list, folio:make)?Routing Complexity:
/posts vs. /posts/1) that require priority rules?/es/about)? If so, how will locales be handled (middleware, subdomains, or path prefixes)?Performance Requirements:
route:cache or Folio’s render() method?folio_pages.slug)?Team Adoption:
Legacy Integration:
Extensibility:
BlogPost, Product) beyond Folio’s default Page?ViewMatched) for analytics or A/B testing?Folio is optimized for Laravel-based stacks and integrates natively with:
folio_pages.Non-Laravel Stacks:
UrinatorBundle or custom route generators.| Phase | Action Items | Tools/Commands | Risks |
|---|---|---|---|
| Assessment | Audit existing routes for conflicts, priorities, and middleware dependencies. | php artisan route:list |
Route overlaps may require manual resolution. |
| Pilot | Migrate non-critical routes (e.g., /about, /blog) to Folio. |
php artisan folio:install |
Limited impact if pilot fails; roll back to original routes. |
| Core Integration | Replace routes/web.php with Folio for content-heavy sections (e.g., marketing pages). |
php artisan folio:make Page + database migration |
Middleware/termination issues may arise; test with php artisan folio:list. |
| Legacy Coexistence | Use route middleware to redirect old paths to Folio routes (e.g., Route::get('/old-path', fn() => redirect()->route('new-folio-route'))). |
Laravel’s redirect()->route() |
Redirect loops if not carefully mapped. |
| Admin UI | Build a Nova resource or custom UI for managing folio_pages. |
Laravel Nova, Filament, or custom Blade admin panel | Requires additional development effort. |
| Optimization | Cache routes (php artisan route:cache) and optimize folio_pages queries (e.g., add slug index). |
php artisan route:cache + database indexing |
Cache invalidation may need custom logic for dynamic pages. |
| Testing |
How can I help you explore Laravel packages today?