无法声明类控制器,因为名称已被使用 [英] Cannot declare class Controller, because the name is already in use
问题描述
我最近将一个 Laravel 4.2 项目迁移到了 5.0.到目前为止,我已经完成了所有必要的步骤,但我不断收到错误消息.
I recently migrated a laravel 4.2 project to 5.0. So far I have completed all the necessary steps but I keep getting an error.
无法声明类控制器,因为名称已被使用
Cannot declare class Controller, because the name is already in use
我的控制器按照 laravel 在升级指南中的说明进行了更改.
My Controller is changed as provided by laravel in the upgrade guide.
<?php
use IlluminateFoundationBusDispatchesCommands;
use IlluminateRoutingController as BaseController;
use IlluminateFoundationValidationValidatesRequests;
abstract class Controller extends BaseController {
use DispatchesCommands, ValidatesRequests;
}
此外,我已将其添加到我的 composer.json 的 classmap 指令中.
Also I have added it to the classmap directive of my composer.json.
"autoload": {
"classmap": [
"database",
"app/Http/Controllers"
],
"psr-4": {
"App\": "app/"
}
},
到目前为止我找不到任何解决方案,所以如果你们知道该怎么做,它会帮我很多:) 提前致谢!
I couldn't find any solution so far so if you guys know what to do it would help me out a lot :) thanks in advance!
推荐答案
从您的类映射中删除 "app/Http/Controllers"
.
Remove the "app/Http/Controllers"
from your classmap.
在 use
块上方添加 namespace AppHttpControllers;
.
然后运行composer dump-auto
这篇关于无法声明类控制器,因为名称已被使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!