Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

laravel - Cannot declare class Controller, because the name is already in use

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

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;

}

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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Remove the "app/Http/Controllers" from your classmap.

Add namespace AppHttpControllers; above your use blocks.

Then run composer dump-auto


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...