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

时间:2015-08-29 11:40:19

标签: php laravel phpstorm laravel-routing laravel-5.1

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

  

糟糕,看起来出了问题。

     

1/1

     

routes.php第16行中的FatalErrorException:

     

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

     

在routes.php第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.
|
*/

use Illuminate\Routing\Route;

Route::get('/', function () {
    return view('welcome');
});

3 个答案:

答案 0 :(得分:26)

导入错误:

use Illuminate\Routing\Route;

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

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

use Illuminate\Support\Facades\Route;

答案 1 :(得分:0)

使用VERSION = '5.2.30'

的Laravel zendserver enterprise

从zend服务器开始C:\Program Files (x86)\Zend\ZendServer\data\plugins\laravel\zray\ZRay.php,更改第193行

if (get_class($route) != 'Illuminate\Routing\Route') {

if (get_class($route) != 'Illuminate\Support\Facades\Route') {   

答案 2 :(得分:-1)

对此进行评论:

// use Symfony\Component\Routing\Route; 

使用此:

use Illuminate\Support\Facades\Route;