laravel 如何修复 [ErrorException] php artisan serve 命令运行时,带有非复合名称“App”的 use 语句没有效果错误显示在 cmd 上

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36539742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:35:14  来源:igfitidea点击:

How to fix [ErrorException] the use statement with non-compound name 'App' has no effect error displayed on cmd when php artisan serve command run

laravelcmdlocalhostlaravel-5.2artisan

提问by Lish

result-when type php artisan serve

结果-何时键入 php artisan serve

When I try php artisan serve command at my terminal it gives below error.Can any body help me to fix this issue?

当我在终端上尝试 php artisan serve 命令时,它给出了以下错误。有人可以帮我解决这个问题吗?

ErrorExceptionThe use statement with non-compound name 'App' has no effect

ErrorException具有非复合名称“App”的 use 语句无效

回答by Y. Joy Ch. Singha

remove

消除

use App;

from your route.php file, it will work for sure. Thanks.

从您的 route.php 文件中,它肯定会起作用。谢谢。

回答by Lish

I hereby post the answer for my own question as I found answer for this and hope this may helpful others in future.

我在此发布我自己问题的答案,因为我找到了这个问题的答案,希望这可以在未来对其他人有所帮助。

Before : I just used 'use App' only at routes.php Now : When use 'use App\Http\Controllers' problem solved.

之前:我只在routes.php 中使用了'use App' 现在:当使用'use App\Http\Controllers' 问题解决了。

回答by Liuver Reynier Durán Pérez

Probably you add 'use App;' in some of your Laravel files, and artisan is parsing the line as an error. To know which line/file is the error, go to the log file (storage/logs/) and check it out. Then remove that line from the file.

可能您添加了“使用应用程序;” 在您的某些 Laravel 文件中,工匠正在将该行解析为错误。要知道哪一行/文件是错误,请转到日志文件 (storage/logs/) 并检查它。然后从文件中删除该行。