Having a folder with multiple files allows us to avoid one big file that gets too long and unmanageable.
-
Create a folder in app directory named "Helpers"
-
Run command "php artisan make:provider HelperServiceProvider"
-
Within the register method of Providers/HelperServiceProvider.php add below lines:
foreach (glob(app_path().'/Helpers/*.php') as $filename){ require_once($filename); }
-
Register the service provider in config/app.php in the providers array
App\Providers\HelperServiceProvider::class,
-
Run command "composer dump-autoload"