Reputation: 18010
Trying the following config to load my models from root namespace failed. any alternative?
"autoload": {
"psr-4": {
"\\": "app/Models"
}
},
The following works but I have to run dumpautoload
each time I create a new class.
"classmap": [
"app/Models"
],
Any suggestion?
Upvotes: 4
Views: 837
Reputation: 3409
Instead of "\\"
, you should map ""
to "app/Models"
. Quoting from composer docs:
If you want to have a fallback directory where any namespace will be looked for, you can use an empty prefix like:
{ "autoload": { "psr-4": { "": "src/" } } }
So, in your case:
{
"autoload": {
"psr-4": {
"": "app/Models"
}
}
}
Upvotes: 2