AGENT SKILL

folio-routing

Creates file-based routes with Laravel Folio. Activates when creating new pages, setting up routes, working with route parameters or model binding, adding middleware to pages, working with resources/views/pages; or when the user mentions Folio, pages, file-based routing, page routes, or creating a new page for a URL path.

License 许可
MIT
最近更新
2026-11-13
Stars
★ 54
Forks
22

01 前言 Front Matter

name
folio-routing
license
MIT
metadata
{ "author": "laravel" }
description
Creates file-based routes with Laravel Folio. Activates when creating new pages, setting up routes, working with route parameters or model binding, adding middleware to pages, working with resources/views/pages; or when the user mentions Folio, pages, file-based routing, page routes, or creating a new page for a URL path.

03 SKILL.md 正文

Folio Routing

Documentation

Use search-docs for detailed Folio patterns and documentation.

Basic Usage

Laravel Folio is a file-based router that creates a new route for every Blade file within the configured directory.

Pages are usually in resources/views/pages/ and the file structure determines routes:

  • pages/index.blade.php → /
  • pages/profile/index.blade.php → /profile
  • pages/auth/login.blade.php → /auth/login

Listing Routes

You may list available Folio routes using php artisan folio:list or using the list-routes tool.

Creating Pages

Always create new folio pages and routes using php artisan folio:page [name] following existing naming conventions.

<!--Example folio:page Commands for Automatic Routing-->

// Creates: resources/views/pages/products.blade.php → /products
php artisan folio:page "products"

// Creates: resources/views/pages/products/[id].blade.php → /products/{id}
php artisan folio:page "products/[id]"

// Creates: resources/views/pages/users/[User].blade.php → /users/{user} (implicit model binding)
php artisan folio:page "users/[User]"

Route Parameters vs. Model Binding

Use the correct filename token based on intent:

  • [id] (lowercase) captures a plain route parameter string
  • [User] (capitalized model class) enables implicit Eloquent model binding
  • [Post:slug] binds by a custom key instead of id

Model binding is case-sensitive in the filename. Avoid [user] when you expect a User model instance.

<!-- Route Parameter vs Model Binding Example -->

{{-- pages/users/[id].blade.php --}}
<div>User ID: {{ $id }}</div>

{{-- pages/users/[User].blade.php --}}
<div>User ID: {{ $user->id }}</div>

Named Routes

Add a name at the top of each new Folio page to create a named route that other parts of the codebase can reference.

<!-- Named Routes Example -->

use function Laravel\Folio\name;

name('products.index');

Middleware

<!-- Middleware Example -->

use function Laravel\Folio\{name, middleware};

name('admin.products');
middleware(['auth', 'verified']);

Page Content Patterns

Folio pages are normal Blade files. Include practical data-loading code when creating or editing pages.

<!-- Inline Query Example in a Folio Page -->

@php
use App\Models\Post;

$posts = Post::query()
    ->whereNotNull('published_at')
    ->latest('published_at')
    ->get();
@endphp

<ul>
    @foreach ($posts as $post)
        <li>{{ $post->title }}</li>
    @endforeach
</ul>

<!-- Render Hook Example for View Data -->

<?php
use App\Models\Post;
use Illuminate\View\View;
use function Laravel\Folio\render;

render(function (View $view, Post $post) {
    return $view->with('photos', $post->author->photos);
});
?>

Verification

  1. Run php artisan folio:list to verify route registration
  2. Test page loads at expected URL

Common Pitfalls

  • Forgetting to add named routes to new Folio pages
  • Using [id] or [user] when model binding requires [User]
  • Not following existing naming conventions when creating pages
  • Creating routes manually in routes/web.php instead of using Folio's file-based routing

Folio 404 Debug Checklist

  1. Run php artisan folio:list
  2. If routes are missing, confirm Folio is mounted (folio:install + provider registration, or Folio::path(...)) and pages are under the mounted path
  3. Verify filename-to-route mapping (index.blade.php, nested paths, [id] vs [Model]), then rerun php artisan folio:list

04 同仓库更多 Skills

karuhun-developer
karuhun-developer/ecommerce

tailwindcss-development

Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3/v4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML/CSS component, CSS file audits, build tool configuration, and vanilla CSS.

★ 54
karuhun-developer
karuhun-developer/ecommerce

pulse-development

Handles Laravel Pulse setup, configuration, and custom card development. Activates when installing Pulse; configuring the dashboard or authorization gate; setting up recorders and filtering; building custom Livewire cards; optimizing with Redis ingest or sampling; or when the user mentions /pulse, pulse:check, pulse:work, Pulse::record(), or application monitoring.

★ 54
karuhun-developer
karuhun-developer/ecommerce

pest-testing

Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to write something in Pest, mentions test files or directories (tests/Feature, tests/Unit, tests/Browser), or needs browser testing, smoke testing multiple pages for JS errors, or architecture tests. Covers: test()/it()/expect() syntax, datasets, mocking, browser testing (visit/click/fill), smoke testing, arch(), Livewire component tests, RefreshDatabase, and all Pest 4 features. Do not use for factories, seeders, migrations, controllers, models, or non-test PHP code.

★ 54
karuhun-developer
karuhun-developer/ecommerce

medialibrary-development

Build and work with spatie/laravel-medialibrary features including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.

★ 54
karuhun-developer
karuhun-developer/ecommerce

livewire-development

Use for any task or question involving Livewire. Activate if user mentions Livewire, wire: directives, or Livewire-specific concepts like wire:model, wire:click, wire:sort, or islands, invoke this skill. Covers building new components, debugging reactivity issues, real-time form validation, drag-and-drop, loading states, migrating from Livewire 3 to 4, converting component formats (SFC/MFC/class-based), and performance optimization. Do not use for non-Livewire reactive UI (React, Vue, Alpine-only, Inertia.js) or standard Laravel forms without Livewire.

★ 54
karuhun-developer
karuhun-developer/ecommerce

laravel-best-practices

Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns.

★ 54