Hi all !
Just a simple question. I read on different topic that custom class like helper.php should be autoload by classmap or other by PSR-0 or PSR-4...
My question is when to use what ? Right now I'm using classmap, but is it normal to have to dump-autoload everytime you add a new function to a class autoloaded with classmap ? is it the same with PSR-4 ?
Thanks for sharing your advices.
I have the same question. In Taylor's book, he does this in his example of getting rid of the Models folder:
"autoload": { "psr-0": { "QuickBill": "app/" } }
Excerpt From: Taylor Otwell. “Laravel: From Apprentice To Artisan.” iBooks.
With PSR-0/PSR-4, you don't have to dump-autoload when you add or update a class. With @dwenaus's example, you could put helper.php at app/helper.php with namespace QuickBill, or maybe app/helpers/helper.php with namespace QuickBill\Helpers, and you wouldn't have to dump-autoload changes to helper.php.
I only use classmap for non-namespaced classes which don't fit my normal PSR-4 rules. Specifically, app/database/migrations (see this comment), app/database/seeds/DatabaseSeeder.php and app/test/TestCase.php.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community