I do not know of a way to not use composer dump-autoload, and why wouldn't you do this ?
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.
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
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.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community