Hello I am creating a big Laravel application.
I want to create a punch of helper functions (may be 1000 functions) to be used in templates and modules within the application.
What is the best practice to do these helpers?
i think you have to follow this link http://itsolutionstuff.com/post/how-to-create-custom-helper-in-laravel-5example.html for create custom helper.
First create helpers.php file in following path : app/Http/helpers.php and
Open your composer.json file and add this:
"files": [
"app/Http/helpers.php"
]
then
composer dump-autoload
Now you can use helper function any where.
You can go any of these ways, but probably you'd want to create helpers.php file with all your helper functions and then autoload this file as Laravel creators did it with vendor\laravel\framework\src\Illuminate\Support\helpers.php
Good practice is to use your own class, of course. But still, since you're using Laravel you might want to use same approach as Laravel creators use.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With