无法声明控制器类,因为该名称已被使用 [英] Cannot declare class Controller, because the name is already in use

查看:44
本文介绍了无法声明控制器类,因为该名称已被使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近将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 Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;

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" .

use 块上方添加 namespace App \ Http \ Controllers; .

然后运行 composer dump-auto

这篇关于无法声明控制器类,因为该名称已被使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆