middleware

Inspect, modify, or reject HTTP requests via Laravel middleware pipelines.

3|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/codebar-ag/coding-guidelines --skill middleware-codebar-ag
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: middleware
Source: https://github.com/codebar-ag/coding-guidelines/tree/main/resources/boost/skills/middleware
Command: npx skills add https://github.com/codebar-ag/coding-guidelines --skill middleware-codebar-ag

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Middleware centralizes cross-cutting concerns like authentication, rate limiting, header manipulation, and request/response logging, keeping controllers focused on business logic.

Core Features & Use Cases

  • Centralizes request/response processing in app/Http/Middleware, enabling consistent authentication, throttling, header management, and logging across routes.
  • Ensures code is clean by separating concerns and enforcing the pipeline order, with clear registration and grouping guidelines.
  • Use Case: Apply a security middleware to protect sensitive routes or apply a throttle middleware to limit request rates per user.

Quick Start

Create your first middleware class under app/Http/Middleware, register it in bootstrap/app.php, and apply it to a group of routes.

Frequently Asked Questions about middleware

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Laravel middleware for authentication and throttling?

To set up Laravel middleware, create a class under app/Http/Middleware, register it in bootstrap/app.php using withMiddleware, and apply it to route groups to enforce authentication and throttling.

What is HTTP middleware used for in web applications?

HTTP middleware inspects, modifies, or rejects incoming requests to centralize cross-cutting concerns like authentication, rate limiting, header manipulation, and logging, keeping controllers focused on business logic.

Can I apply middleware to a specific group of routes in Laravel?

Yes, you can apply middleware to specific route groups in Laravel. After registering it in bootstrap/app.php, enforce it at the group level to protect sensitive routes or limit request rates per user.

When should I use middleware instead of putting logic in controllers?

Use middleware instead of controllers for cross-cutting concerns like authentication, throttling, header management, and logging. This separates concerns, enforces pipeline order, and keeps controllers focused on business logic.

Does Laravel middleware support modifying HTTP request headers?

Yes, Laravel middleware supports modifying HTTP request headers. By placing logic in app/Http/Middleware, you can inspect and manipulate headers consistently across designated routes before requests reach the controller.

Why create custom middleware instead of using built-in Laravel features?

Creating custom middleware provides a standardized pipeline to enforce specific security rules or header manipulations that built-in features lack, ensuring consistent request processing and clean separation of concerns across your application.