4

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?

1 Answer 1

2

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" } } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.