Ad

Key Is A Duplicate In ./composer.json

- 1 answer

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.

Ad

Answer

You can't have duplicated keys in your psr-4 mapping. It is supposed to define the root folder for given namespace and a namespace cannot have multiple roots.

Remove one of the mappings for Classified\ namespace.

Ad
source: stackoverflow.com
Ad