Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Key is a duplicate in ./composer.json

Am trying structure my app in such a way that all my models will be in a dedicated directory(in my case Classified). I created the directory with Laravel app directory and added it to my my composer.json file. Below is the structure of my composer.json file:

"autoload": {
    "classmap": [
        "database"
    ],
    "psr-4": {
        "Classified\\": "app/",
        "Classified\\": "app/Classified"
    }
},

Then I run composer dump-autoload in my terminal but I keep getting "Key Classified\ is a duplicate in ./composer.json at line 29 " and when I tried viewing my app in the browser i get:

Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist' in /home/vagrant/Workspace/codulabproducts/classified/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 736.

Line 29 in my composer.json file is

"Classified\\": "app/Classified"

I don't know what am doing wrong because I have followed these steps in my other project and everything went well.

like image 685
ammezie Avatar asked Jan 13 '16 09:01

ammezie


1 Answers

You can define more than one directory for a namespace prefix. But in that case the value for the key must be a list and not a string (see the second example in the documentation):

{
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "Classified\\": ["app/", "app/Classified"]
        }
    }
}
like image 192
xabbuh Avatar answered Sep 26 '22 14:09

xabbuh