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

SparkyRih's avatar

auth.basic uses wrong class?

So I'm simply trying to use auth.basic to authenticate a single route, but it throws this error: Method Illuminate\Auth\RequestGuard::basic does not exist.

Any help, I've been searching for hours, but I can't find any solution...

0 likes
5 replies
SparkyRih's avatar

Yes, those 2 columns are both in the users table.

jlrdw's avatar

@SparkyRih here's route I tested:

Route::get('dog/indexadmin', 'DogController@indexAdmin')->middleware('auth.basic');

Worked perfect.

Newer way is:

Route::get('dog/indexadmin', [DogController::class, 'indexAdmin'])->middleware('auth.basic');
1 like
SparkyRih's avatar

I'm trying to use the middleware with the scribe documentation package, but even when trying to setup auth.basic with a route like you do, it throws the same error as described in my first post.

The RequestGuard does not appear to have the basic() method, the SessionGuard however does...

SparkyRih's avatar

Got it, I needed to set the default guard to web, it was set to sanctum (which I'm actually not using anymore since I implemented Passport). Everything seems to be working perfectly fine now :)

1 like

Please or to participate in this conversation.