Laravel Artisan Generator Command: The make:provider Command

December 7, 2016 —John Koster

The make:provider command can be used to quickly create new service providers for your application. It accepts only the name to be used for the newly generated service provider class and file. Newly generated providers are stored in the app/Providers directory.

This command will not overwrite any existing service provider classes that have the same name. An error stating Provider already exists! will be displayed instead.

The following example demonstrates how to call the make:provider command:

1# Generate a new service provider.
2php artisan make:provider DrinksProvider

The generated class would be stored in the app/Providers/DrinksProvider.php file and would contains contents similar to the following:

1<?php
2 
3namespace App\Providers;
4 
5use Illuminate\Support\ServiceProvider;
6 
7class DrinksProvider extends ServiceProvider
8{
9 /**
10 * Bootstrap the application services.
11 *
12 * @return void
13 */
14 public function boot()
15 {
16 //
17 }
18 
19 /**
20 * Register the application services.
21 *
22 * @return void
23 */
24 public function register()
25 {
26 //
27 }
28}

The make:provider command is also capable of generated namespaced classes. Accomplish this by separating namespace sections using the \ when supplying the provider name. A nested directory will be created and the correct namespace will be set on the generated class.

Some absolutely amazing
people

The following amazing people help support this site and my open source projects ♥️
If you're interesting in supporting my work and want to show up on this list, check out my GitHub Sponsors Profile.