Laravel Make Facades

Laravel Make Facades Package



Clean Code Studio package to generate  Facades in a single command -  php artisan make:facade MyCoolService


composer require clean-code-studio/laravel-make-facades --dev


php artisan vendor:publish

Select: CleanCodeStudio\MakeFacades\ServiceProvider

Define Service Config Settings


Default Service Config Settings


return [

   // Directory path save your facades

   'path' => 'app/facades',

  // Namespace Of Your Facades

  'namespace' => 'App\\Facades',

  // Providers path (@see

  'providers_path' => 'app/Providers',


  // This will find all of the aliases and services defined in your path settings and

  // 1. Bind the service classes for each facade to the service container automatically

  // 2. Register aliases for each facade base on the Class Name the Facade Reference to the service container automatically

  'auto_alias_facades' => true,


Make Facades

php artisan make:facade MyCoolService

Default ServiceClass Scaffold

Default creation format: App\Facades\MyCoolService\MyCoolService.php


namespace App\Facades\MyCoolService;

class MyCoolService


    // create MyCoolService class


Default ServiceClassFacade Scaffold

By Default created at App\Facades\MyCoolService\MyCoolServiceFacade.php


namespace App\Facades\MyCoolService;

use Illuminate\Support\Facades\Facade;

class MyCoolServiceFacade extends Facade


    protected static function getFacadeAccessor()


        return 'MyCoolService';



Important Note

If 'auto_alias_facades' => false in config/make-facade.php then you need to

Bind generated service class (Example MyCoolServiceClass) to the service container whenever you create a new facade and service scaffold via running the make:facade command.

If auto_alias_facades is set to true then it will register the service class (Example MyCoolServiceClass) to the service container automatically.



Open Service Config File