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

哎呀,好像出了什么事.

1/1

routes.php第16行中的FatalErrorException:

调用未定义的方法Lightiate\Routing\Route::Get()

在routes.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');
});

推荐答案

这种导入是错误的:

use Illuminate\Routing\Route;

因为Laravel注册了一个全局别名Route,所以实际上不需要导入任何类.

If you want to import the right class, that would be:

use Illuminate\Support\Facades\Route;

Laravel相关问答推荐

如何使用动态翻译键翻译 Laravel硬编码字符串(还有 1 个错误)..(验证异常类)

单个对象的Eloquent 计数是错误的

如何在 laravel 5.3 中验证没有 auth:api 中间件的用户?

Laravel:使用 Input::old 时 textarea 不会重新填充

如何为路由 laravel 5 使用OR中间件

laravel 控制器中的全局变量

Laravel:Blade foreach 循环 bootstrap 列

Laravel 5.6 - 如何在 api 控制器中获取 auth()->user() 或 $response->user()?

Laravel 将 JSON 转换为数组?

Laravel 5.3 - 将多个文件附加到 Mailables

Laravel excel maatwebsite 3.1 导入,excel 单元格中的日期列返回为未知格式数字.如何解决这个问题?

Laravel Eloquent 在子查询中有两个WHERE NOT IN

如何在 php Laravel 中对关联数组进行排序

如何仅在Blade模板存在时才包含它?

日期验证 - 如何本地化/翻译字符串今天和明天

Laravel 4:将什么作为参数传递给 Url 类?

将值插入隐藏输入 Laravel Blade

Laravel 从公共删除目录

Laravel Nova 显示用户友好的资源名称

laravel中的动态网址?