Laravel

Laravel Invokable Controllers: Single Action

January 16, 2026 1 min read 18 views

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
Share this post:

Related Posts

Comments (0)

Please log in to leave a comment. Log in

No comments yet. Be the first to comment!