Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel say that Auth guard [] is not defined

I'm beginer and I start learn and code with laravel... To enable user login nad registration I write this (as I see on one tutorilal):

at routes.php

 Route::controllers([
     'auth'=>'Auth\AuthController',
     'password'=>'Auth\PasswordController', ]);

and now when I type: http://localhost:8888/auth/login I get error:

InvalidArgumentException in AuthManager.php line 71: Auth guard [] is not defined.

enter image description here

Also in view folder there is no auth directory and login.blade.php files and other.

like image 733
MonkeyBusiness Avatar asked Dec 06 '15 10:12

MonkeyBusiness


People also ask

How Guard is defined in Laravel?

Guards define how users are authenticated for each request. For example, Laravel ships with a session guard which maintains state using session storage and cookies. Providers define how users are retrieved from your persistent storage.

What is the default guard in Laravel?

By default, web routes are configured to use the web guard and API routes are configured to use the api guard, and unless otherwise specified, Laravel will use the web guard by default.

What is Auth guard Laravel 8?

Laravel guards define how users are authenticated for each request. Laravel by default provides some guards for authentication. You can check the default guards in the config/auth. php file.

What is Auth :: Guard?

This will check that the user is authenticated by api_token instead of session. Then you can get an instance of the user by Auth::guard('api')->user() instead of Auth::user() which is the same as Auth::guard('web')->user() You would use this if your application has an API endpoint allowed for logged in users only.


2 Answers

In case you edited your config/auth.php, e.g. to add another guard and your config is cached, your guards may not be reloaded. If you experience this problem, clearing the config will fix it.

$php artisan config:clear or $php artisan config:cache

I'm using laravel 5.5

like image 22
Jason Tumusiime Avatar answered Sep 17 '22 14:09

Jason Tumusiime


Make sure that your config/auth.php is updated if you've upgraded from 5.1.x to 5.2.

https://github.com/laravel/laravel/blob/v5.2.0/config/auth.php

like image 52
Matt Avatar answered Sep 17 '22 14:09

Matt