I would like to ask you why I'm getting conflict error after added this to composer.json:
"autoload": {
"psr-4": {
"App\\": "app/",
"Models\\": "app/Models/",
"Controllers\\": "app/Http/Controllers/"
},
...
}
and namespace everything inside such as "app\\Models\\People\\Admin.php" be
namespace Models\People;
I have searched for this problem before with no luck, did I miss something?
Thank you!
You are getting this error because the autoloader is including all of the classes under App\\
first, which includes all of the classes under App\\Models
and App\\Controllers
too, then re-including these classes again, which causes this conflict.
To illustrate this, here is what is happening:
app
directory.app/Models/People/Admin.php
and include
s it.app/
, it starts looking for class files under app/Models
, finds the Admin.php
class file and include
s it once more.class Admin {}
class Admin {}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.