运行php artisan:未找到类'Route'

时间:2017-07-17 13:10:57

标签: laravel laravel-5

我刚接受了新项目,我遇到了阻塞问题 在没有任何参数的情况下运行php artisan时会抛出以下错误:

[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'Route' not found

运行网站主页时,我有一个例外,日志中的堆栈跟踪如下:

[2017-07-17 13:07:07] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Class 'Route' not found in C:\wamp64\www\myproject\routes\api.php:16
Stack trace:
#0 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\Router.php(329): require()
#1 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\Router.php(285): Illuminate\Routing\Router->loadRoutes('C:\\wamp64\\www\\S...')
#2 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Routing\RouteRegistrar.php(104): Illuminate\Routing\Router->group(Array, 'C:\\wamp64\\www\\S...')
#3 C:\wamp64\www\myproject\app\Providers\RouteServiceProvider.php(71): Illuminate\Routing\RouteRegistrar->group('C:\\wamp64\\www\\S...')
#4 C:\wamp64\www\myproject\app\Providers\RouteServiceProvider.php(38): App\Providers\RouteServiceProvider->mapApiRoutes()
#5 [internal function]: App\Providers\RouteServiceProvider->map()
#6 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(29): call_user_func_array(Array, Array)
#7 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#8 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#9 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#10 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Support\Providers\RouteServiceProvider.php(71): Illuminate\Container\Container->call(Array)
#11 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Support\Providers\RouteServiceProvider.php(30): Illuminate\Foundation\Support\Providers\RouteServiceProvider->loadRoutes()
#12 C:\wamp64\www\myproject\app\Providers\RouteServiceProvider.php(28): Illuminate\Foundation\Support\Providers\RouteServiceProvider->boot()
#13 [internal function]: App\Providers\RouteServiceProvider->boot()
#14 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(29): call_user_func_array(Array, Array)
#15 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(87): Illuminate\Container\BoundMethod::Illuminate\Container\{closure}()
#16 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\BoundMethod.php(31): Illuminate\Container\BoundMethod::callBoundMethod(Object(Illuminate\Foundation\Application), Array, Object(Closure))
#17 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Container\Container.php(539): Illuminate\Container\BoundMethod::call(Object(Illuminate\Foundation\Application), Array, Array, NULL)
#18 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(788): Illuminate\Container\Container->call(Array)
#19 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(771): Illuminate\Foundation\Application->bootProvider(Object(App\Providers\RouteServiceProvider))
#20 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(App\Providers\RouteServiceProvider), 17)
#21 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(772): array_walk(Array, Object(Closure))
#22 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Bootstrap\BootProviders.php(17): Illuminate\Foundation\Application->boot()
#23 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(208): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#24 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(162): Illuminate\Foundation\Application->bootstrapWith(Array)
#25 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(146): Illuminate\Foundation\Http\Kernel->bootstrap()
#26 C:\wamp64\www\myproject\vendor\laravel\framework\src\Illuminate\Foundation\Http\Kernel.php(116): Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter(Object(Illuminate\Http\Request))
#27 C:\wamp64\www\myproject\public\index.php(53): Illuminate\Foundation\Http\Kernel->handle(Object(Illuminate\Http\Request))
#28 {main}

我对laravel很新,所以这可能是一个新手的错误,但我没有设法自己找到解决方案。有人能帮帮我吗? 谢谢你的时间。

修改
罪魁祸首是一位同事,他想在config/app.php的末尾添加一个“特征”数组,并将其命名为“别名”。所以之前定义的所有内容都已丢失。

3 个答案:

答案 0 :(得分:0)

感谢Thomas Moors,发现了问题 在app.php中,有什么期望:

'aliases' => [
[...]
],
'features' => [
[...]
    ],

除了'特征'之外,还有一个错误:

'aliases' => [
[...]
],
'aliases' => [
[...]
    ],

所以是的,没有任何事情像预期的那样奏效。谢谢大家。

答案 1 :(得分:0)

我认为这个问题现在已经有一个多月了,

转到您已使用Route :: method_name()的文件,然后通过 - >

将Route类导入其中
use Route;

这在实现

的App \ Providers \ AppServiceProvider @ boot()中很常见
Route::resourceVerbs([...]);

如果有帮助,请告诉我

答案 2 :(得分:0)

就我而言,我输入的是 Routes 而不是 Route。 所以要注意类似这样的错误。把句子写好。