gpt4 book ai didi

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

转载 作者:可可西里 更新时间:2023-10-31 22:17:55 24 4
gpt4 key购买 nike

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

Whoops, looks like something went wrong.

1/1

FatalErrorException in routes.php line 16:

Call to undefined method Illuminate\Routing\Route::get()

in routes.php line 16

这是我的 routes.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

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

use Illuminate\Support\Facades\Route;

关于php - 调用未定义的方法 Illuminate\Routing\Route::get(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32285647/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com