Support the ongoing development of Laravel.io →
Configuration
Last updated 3 months ago.
0

I do not know of a way to not use composer dump-autoload, and why wouldn't you do this ?

Last updated 3 months ago.
0

I think I would still need to use namespaces for the classes, right? That is my primary issue, what namespace shoud I use in my situation.

I'm not avoiding Composer, I'm just new to it and this seems like the easier way :) If you add the folder in global.php, it's the same.

Last updated 3 months ago.
0

You can't do this using laravel's addDirectories. If you look at the source for that method, it will add the directory to an array, then when you call a class, it will search only for that class in that directory, non-recursively (as you have discovered). Why wouldn't you do this with composer? It's easier, and more manageable. Open up your composer.json, add "app/viewmodels" to the existing "classmap" array (you'll find other directories like app/models, app/controllers, etc there), then run composer dump-autoload

Last updated 3 months ago.
0

OK, doing it with composer did the trick. I'll try to use it with psr-0, with namespaces to see how that works in my case, because if I add it just in the autoload->classmap I'll need to run dump-autoload every time I add a new class.

I was asking to use it without composer, because after the site is live, maybe I'll have to add new classes and I don't know if I'll be able to use composer on the server. I'll copy the new classes via FTP, but they won't work until I run dump-autoload there.

Last updated 3 months ago.
0

Sign in to participate in this thread!

Full Stack Europe

Your banner here too?

andrejmk andrejmk andrejmk Joined 28 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

The Laravel portal for problem solving, knowledge sharing and community building.

© 2022 Laravel.io - All rights reserved.