Laravel Invokable Controllers: Single Action
January 16, 2026
•
1 min read
•
18 views
Table of Contents
Single action controllers:
Create Invokable Controller
php artisan make:controller ShowDashboard --invokable
Controller Structure
class ShowDashboard extends Controller
{
public function __invoke(Request $request)
{
return view('dashboard', [
'stats' => $this->getStats(),
]);
}
}
Route Definition
Route::get('/dashboard', ShowDashboard::class);
Benefits
- Clear responsibility
- No method naming
- Easy to find
- Better organization
Related Posts
Laravel Sanctum API Authentication Complete Guide
Build secure API authentication with Laravel Sanctum for SPAs and mobile apps.
Laravel Rate Limiting: Protect Your Application
Implement rate limiting to protect your Laravel application from abuse.
Laravel Blade Components: Build Reusable UI
Create powerful reusable components with Laravel Blade.
Comments (0)
No comments yet. Be the first to comment!