查看 [auth.login] 未找到 laravel 5
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32354532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
view [auth.login] not found laravel 5
提问by Sakshi Garg
I had made the routes in routes.phpfile
我已经在routes.php文件中创建了路由
Route::controller('auth','Auth\AuthController');
Route::controller('auth','Auth\AuthController');
Auth/AuthController.phpfile is
Auth/AuthController.php文件是
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Auth\Guard;
use App\Http\Requests\Auth\LoginRequest;
use App\Http\Requests\Auth\RegisterRequest;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* the model instance
* @var User
*/
protected $user;
/**
* The Guard implementation.
*
* @var Authenticator
*/
protected $auth;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct(Guard $auth, User $user)
{
$this->user = $user;
$this->auth = $auth;
$this->middleware('guest', ['except' => ['getLogout']]);
}
/**
* Show the application registration form.
*
* @return Response
*/
public function getRegister()
{
return view('auth.register');
}
/**
* Handle a registration request for the application.
*
* @param RegisterRequest $request
* @return Response
*/
public function postRegister(RegisterRequest $request)
{
//code for registering a user goes here.
$this->auth->login($this->user);
return redirect('/todo');
}
/**
* Show the application login form.
*
* @return Response
*/
public function getLogin()
{
return view('auth.login');
}
/**
* Handle a login request to the application.
*
* @param LoginRequest $request
* @return Response
*/
public function postLogin(LoginRequest $request)
{
if ($this->auth->attempt($request->only('email', 'password')))
{
return redirect('/todo');
}
return redirect('/login')->withErrors([
'email' => 'The credentials you entered did not match our records. Try again?',
]);
}
/**
* Log the user out of the application.
*
* @return Response
*/
public function getLogout()
{
$this->auth->logout();
return redirect('/');
}
}
When I hit this auth/login it give me the error -- InvalidArgumentException in FileViewFinder.php line 137: View [auth.login] not found. Can anyone help me out to resolve this issue.?
当我点击这个身份验证/登录时,它给了我错误——FileViewFinder.php 第 137 行中的 InvalidArgumentException:未找到查看 [auth.login]。谁能帮我解决这个问题。?
回答by lucasvm1980
Go to
去
bootstrap/cache
引导程序/缓存
And rename config.php to config.php_
并将 config.php 重命名为 config.php_
Im pretty sure you have copied from another site and moved also the cache
我很确定您已经从另一个站点复制并移动了缓存
回答by Marco
if you just startet a new project, there aren't auth views out of the box, just as Peter Fox mentioned above.
如果您刚刚开始一个新项目,则没有开箱即用的 auth 视图,就像上面提到的 Peter Fox 一样。
You will need to enter
您需要输入
php artisan make:auth
to create these views.
创建这些视图。
回答by femotizo
i got mine to work after modifing the auth.login directroy from /Authto /authcan be located at laravel/resources/views/Auth
在将 auth.login 目录从/Auth 修改为/auth后,我开始工作了,可以位于 laravel/resources/views/Auth
回答by Angelica Landazabal
In your file web.phpinside the directory routes, delete or comment the line Auth::routes();
在目录routes内的文件web.php 中,删除或注释Auth::routes();
回答by Roshan Perera
This may happened when we are going to do fresh setup. try cleaning first
当我们要进行全新设置时,可能会发生这种情况。先尝试清洁
php artisan view:clear
php artisan config:cache
php artisan route:cache