Laravel说Auth guard []没有定义

Mon*_*ess 15 php authentication routes laravel laravel-5.1

我是初学者,我开始学习并使用laravel进行编码...为了启用用户登录nad注册,我写这个(正如我在一个tutorilal上看到的):

在routes.php

 Route::controllers([
     'auth'=>'Auth\AuthController',
     'password'=>'Auth\PasswordController', ]);
Run Code Online (Sandbox Code Playgroud)

现在当我键入:http:// localhost:8888/auth/login我收到错误:

AuthManager.php第71行中的InvalidArgumentException:未定义Auth guard [].

在此输入图像描述

同样在视图文件夹中没有auth目录和login.blade.php文件等.

小智 19

如果已从5.1.x升级到5.2,请确保更新config/auth.php.

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


小智 8

如果您编辑了config/auth.php,例如添加了另一个防护,并且配置被缓存,则可能不会重新加载防护。如果您遇到此问题,清除配置将解决此问题。

$php artisan config:clear 要么 $php artisan config:cache

我正在使用laravel 5.5


小智 5

这可能是 config/auth.php 文件中的问题,其中“defaults”数组在 Laravel 5.2 上设置了一个不存在的防护。

  • 这应该是一条评论 (2认同)

Lok*_*sen 5

这个问题的主要原因是你的系统无法检测到新创建的守卫。赶紧跑

php artisan config:clear
php artisan config:cache
Run Code Online (Sandbox Code Playgroud)

如果您无法在共享托管中运行上述 artisan 命令或项目,请将以下代码写入您的 web.php 文件

Route::get('/clear', function() {

    Artisan::call('cache:clear');
    Artisan::call('config:clear');
    Artisan::call('config:cache');
    Artisan::call('view:clear');
    Artisan::call('route:clear');

    return "Cleared!";

});
Run Code Online (Sandbox Code Playgroud)

现在,在您的基本网址后面写上“clear”,然后按 Enter 键。希望您的问题能够解决。