skills/iurygdeoliveira/labsis-kit/scaffold-middleware

scaffold-middleware

SKILL.md

Laravel Middleware Pattern Skill

Use this skill when implementing request filtering or modification logic.

Rules

1. Modern Registration (Laravel 12)

  • Do NOT look for app/Http/Kernel.php (it is gone).
  • Register middleware in bootstrap/app.php using the ->withMiddleware() callback.
  • Use append() for global or alias() for route-specific.
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(EnsureTokenIsValid::class);
    $middleware->alias([
        'admin' => EnsureUserIsAdmin::class,
    ]);
})

2. Structure

  • Implement the handle method with proper typing.
public function handle(Request $request, Closure $next): Response
{
    if (...) {
        return redirect('/home');
    }
    return $next($request);
}
Weekly Installs
3
GitHub Stars
31
First Seen
Jan 24, 2026
Installed on
claude-code2
windsurf1
trae1
opencode1
codex1
antigravity1