Call to undefined method Illuminate\Routing\Route:

2019-02-13 19:41发布

I have just installed Laravel 5.1, visited the home page of my app and i get the following error:

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

This is my routes.php file:

<?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');
});

2条回答
Explosion°爆炸
2楼-- · 2019-02-13 20:08

Laravel VERSION = '5.2.30' using zendserver enterprise

On C:\Program Files (x86)\Zend\ZendServer\data\plugins\laravel\zray\ZRay.php from zend server, change line 193

From

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

To

if (get_class($route) != 'Illuminate\Support\Facades\Route') {   
查看更多
聊天终结者
3楼-- · 2019-02-13 20:09

This import is wrong:

use Illuminate\Routing\Route;

You actually don't have to import any class as Laravel registers a global alias Route.

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

use Illuminate\Support\Facades\Route;
查看更多
登录 后发表回答