1 //Into the console
2 php artisan make:provider GlobalFunctionsServiceProvider
3
1 //App\Providers\GlobalFunctionsServiceProvider.php
2
3 public function register()
4 {
5 require_once base_path().'/app/Functions/GlobalFunctions.php';
6 }
7
1 //Use your function anywhere within your Laravel app
2 first_function();
3 second_function();
4
1Composer //Autload whitin composer.json method
2|
3|--->Laravel App //My method
4 |
5 |--->Controller //Trait method
6 |--->Blade //Trait method
7 |--->Listener //Trait method
8 |--->...
9
1 //App\Config\App.php
2
3 'providers' => [
4
5 /*
6 * Laravel Framework Service Providers...
7 */
8 Illuminate\Auth\AuthServiceProvider::class,
9 ...
10 Illuminate\Validation\ValidationServiceProvider::class,
11 Illuminate\View\ViewServiceProvider::class,
12 App\Providers\GlobalFunctionsServiceProvider::class, //Add your service provider
13