The key is a duplicate in. / Composer.json

I am trying to structure my application in such a way that all my models will be in a specialized directory (in my case, "Classified"). I created a directory with the Laravel application directory and added it to 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 the dump-autoload linker in my terminal, but I keep getting "Key Class \" - this is a duplicate of. /composer.json on line 29 "and when I tried to view my application in a browser, I get:

Fatal error: throw a "ReflectionException" exception with the message "App class" \ Http \ Kernel does not exist "in / home / vagrant / Workspace / codulabproducts / category / vendor / laravel / framework / src / Illuminate / Container / Container. Php in line 736.

Line 29 in my composer.json file

"Classified\\": "app/Classified"

I do not know what I am doing wrong, because I followed these steps in my other project, and everything went well.

+4
source share
2 answers

You cannot duplicate keys in your psr-4 . It is supposed to define the root folder for this namespace, and the namespace cannot have multiple roots.

\.

+2

. , (. ):

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

Source: https://habr.com/ru/post/1624071/


All Articles