Support the ongoing development of Laravel.io →
posted 10 years ago
Configuration
Last updated 2 years ago.
0

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

Last updated 2 years 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 2 years 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 2 years 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 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

andrejmk andrejmk Joined 28 Mar 2014

Moderators

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

Your logo here?

Laravel.io

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

© 2024 Laravel.io - All rights reserved.