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?
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"
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With