WithoutMiddleware
Exclude middleware from a controller class or action method
Description: Excludes middleware from a controller class or individual action methods. Can be combined with only and except options.
Namespace: Illuminate\Routing\Attributes\Controllers\WithoutMiddleware
Usage
Applied to the entire controller:
use Illuminate\Routing\Attributes\Controllers\WithoutMiddleware;
#[WithoutMiddleware('auth')]
class UserController
{
public function index() { /* ... */ }
public function store() { /* ... */ }
}
Applied with only / except restrictions:
#[WithoutMiddleware('auth')]
#[WithoutMiddleware('throttle:60,1', only: ['store'])]
#[WithoutMiddleware('subscribed', except: ['index'])]
class UserController
{
public function index() { /* ... */ }
public function store() { /* ... */ }
}
Applied to individual methods:
#[WithoutMiddleware('auth')]
class UserController
{
#[WithoutMiddleware('verified')]
public function store() { /* ... */ }
public function index() { /* ... */ }
}