I worked on this, and I finally fixed it by putting different puzzles along with this solution:
For Laravel 5:
Step 1. Created app/Helpers folder
Step 2. In the app/Providers folder, create the HelpersServiceProvider.php provider using the following artisan command:
php artisan make:provider HelpersServiceProvider
Step 3. In the HelpersServiceProvider.php file HelpersServiceProvider.php we create an internal foreach loop registration function to retrieve all helper classes as follows:
public function register() { foreach (glob(app_path() . '/Helpers/*.php') as $helpersfilename) { require_once($helpersfilename); } }
Step 4. The following line is added to config/app.php
App\Providers\HelpersServiceProvider::class,
That's all, the solution here is tested and works on all versions of Laravel 5.x. Now you can add unlimited helpers to the helpers folder, they will be automatically added to the system.
Laravel 4 has not yet been verified, but if some of its body, add / edit it for Laravel 4.
source share