调用未定义的方法 Illuminate\Routing\Route::get()

我刚刚安装了Laravel 5.1,访问了我的应用程序的主页,我收到以下错误:

哎呀,看起来好像出了点问题。

1/1

致命错误路线中的异常.php行 16:

调用未定义的方法 Illuminate\Routing\Route::get()

路线.php 16号线

这是我的路线.php文件:

<?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('/', function () {
    return view('welcome');
});

答案 1

此导入错误:

use Illuminate\Routing\Route;

您实际上不必导入任何类,因为Laravel注册了全局别名。Route

如果要导入正确的类,那就是:

use Illuminate\Support\Facades\Route;

答案 2

评论这个:

// use Symfony\Component\Routing\Route; 

使用这个:

use Illuminate\Support\Facades\Route; 

推荐