`我查看了论坛,没有找到任何可以帮助解决这个问题。奇怪的是,我在另一台电脑上有完全相同的文件,并通过xampp运行,由于某种原因,这给了我这个错误。我正在运行一个laravel项目,当我尝试去其中一个页面时会发生这种情况。
<?php
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
// Route::get('/',
// ['as' => 'home',
// 'middleware' => 'role:admin',
// 'uses' => 'PageController@index']);
Route::get('/', function () {
return view('home', ['page_title' => 'Internation Revolving Doors']);
});
Route::get('auth/login', 'Auth\AuthController@getLogin');
Route::post('auth/login', 'Auth\AuthController@postLogin');
Route::get('auth/logout', 'Auth\AuthController@getLogout');
Route::get('auth/register', 'Auth\AuthController@getRegister');
Route::post('auth/register', 'Auth\AuthController@postRegister');
这是控制器
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use Validator;
use Illuminate\Http\Request;
use Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ThrottlesLogins;
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
class AuthController extends Controller
{
/*
|--------------------------------------------------------------------------
| Registration & Login Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users, as well as the
| authentication of existing users. By default, this controller uses
| a simple trait to add these behaviors. Why don't you explore it?
|
*/
use AuthenticatesAndRegistersUsers, ThrottlesLogins;
/**
* Create a new authentication controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest', ['except' => 'getLogout']);
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
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',
]);
}
public function getLogin()
{
return view('auth/login', array("page_title" => "Login"));
}
public function postLogin(Request $request)
{
$data = array(
'email' => $request->get('email'),
'password' => $request->get('password'),
);
if (Auth::attempt($data))
{
return redirect('/');
}
else
{
return redirect('/auth/login');
}
}
public function getLogout()
{
Auth::logout();
return redirect('/');
}
public function getRegister()
{
return view('auth/register', array('page_title' => 'Sign Up'));
}
public function postRegister(Request $request)
{
$data = $request->all();
$validator = $this->validator($data);
if ($validator->fails())
{
return redirect('auth/register');
}
else
{
$user = $this->create($data);
return redirect('/');
}
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return User
*/
protected function create(array $data)
{
if ($data['architect']){
// Assign the role
}
else{
// Assign the role
}
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}