Skip to content

Instantly share code, notes, and snippets.

@manashcse11
Last active September 10, 2017 16:33
Show Gist options
  • Save manashcse11/6ac2d24ccfe71530baf1cd5de64bff47 to your computer and use it in GitHub Desktop.
Save manashcse11/6ac2d24ccfe71530baf1cd5de64bff47 to your computer and use it in GitHub Desktop.
#Laravel #Helper-Service-Provider

Having a folder with multiple files allows us to avoid one big file that gets too long and unmanageable.

  1. Create a folder in app directory named "Helpers"

  2. Run command "php artisan make:provider HelperServiceProvider"

  3. Within the register method of Providers/HelperServiceProvider.php add below lines:

     foreach (glob(app_path().'/Helpers/*.php') as $filename){
         require_once($filename);
     }
    
  4. Register the service provider in config/app.php in the providers array

     App\Providers\HelperServiceProvider::class,
    
  5. Run command "composer dump-autoload"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment