Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bloup's avatar
Level 1

Middleware issue inside Controller

Hi,

I have a problem with controller right know : 'Call to undefined method App\Http\Controllers\AccountController::middleware()'

class AccountController extends Controller { public function __construct(){ $this->middleware('auth'); } }

Anyone has an idea ? Thank you for your help !

0 likes
2 replies
thinkverse's avatar
Level 15

Your base controller class needs to extend Laravel's Illuminate\Routing\Controller to use the middleware method.

<?php
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{ }

The default base controller in App\Http\Controllers\Controller should already do that.

2 likes

Please or to participate in this conversation.