2016-03-08 335 views
1

我是Laravel的新手,我聽說登錄和註冊系統在Laravel中是默認的。但是,我無法利用它。我已經在資源/視圖/內的Auth目錄中放置了登錄和註冊視圖。Laravel身份驗證錯誤

我有這個控制器Auth/AuthController.php

<?php 

namespace App\Http\Controllers\Auth; 

use App\User; 
use Validator; 
use App\Http\Controllers\Controller; 
use Illuminate\Foundation\Auth\ThrottlesLogins; 
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers; 

class AuthController extends Controller 
{ 
    use AuthenticatesAndRegistersUsers, ThrottlesLogins; 

    private $redirectTo = '/loginpage'; 

    public function __construct() 
    { 
     $this->middleware('guest', ['except' => 'getLogout']); 
    } 

    protected function validator(array $data) 
    { 
     return Validator::make($data, [ 
      'name' => 'required|max:255', 
      'email' => 'required|email|max:255|unique:users', 
      'password' => 'required|confirmed|min:6', 
     ]); 
    } 

    protected function create(array $data) 
    { 
     return User::create([ 
      'name' => $data['name'], 
      'email' => $data['email'], 
      'password' => bcrypt($data['password']), 
     ]); 
    } 
} 

的航線有:

// Authentication routes... 
Route::get('auth/login', 'Auth\[email protected]'); 
Route::post('auth/login', 'Auth\[email protected]'); 
Route::get('auth/logout', 'Auth\[email protected]'); 

// Registration routes... 
Route::get('auth/register', 'Auth\[email protected]'); 
Route::post('auth/register', 'Auth\[email protected]'); 

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

但我收到此錯誤:

FatalErrorException in AuthenticatesAndRegistersUsers.php line 11: A precedence rule was defined for Illuminate\Foundation\Auth\AuthenticatesUsers::getGuard but this method does not exist

+0

你檢查了嗎? http://stackoverflow.com/questions/35065996/php-fatal-error-a-precedence-rule-was-defined-for-illuminate-foundation-auth – Musterknabe

+0

沒有這樣的文件'compile.php' @Musterknabe – micky

+0

您可以在您的項目目錄中嘗試在CLI中使用此命令嗎? 'php artisan清編' – Musterknabe

回答

0

如果您正在使用larave 5.2 SSH連接到您的目錄,然後鍵入

php artisan make:auth

(這是在項目的開始做,因爲它可以覆蓋一些看法)。還要確保你已連接到你的分區

+0

嘗試過,但發生類似的錯誤。 – micky

+0

你可以嘗試一個乾淨的項目,然後與你的文件進行比較? – Mike