This package makes the process of creating facades in laravel super easy and with one simple artisan command. For each facade created with this package:
- A Facade file is created in
App\Facadesto define the facade accessor. - A Facade service provider
App\Providers\FacadeServiceProvider.phpis created/edited to bind your implementation class to the facade accessor. - The
FacadeServiceProvideris registered in your app configuration file (config\app.php).
Via Composer
composer require hmones/laravel-facade --devTo publish the package configuration
php artisan vendor:publish --tag=laravel-facade-configThe configuration contains the following values:
<?php
return [
'provider' => [
'name' => 'FacadeServiceProvider',
'namespace' => 'App\Providers',
],
];- The name attribute represents the name of the provider file that will hold all the bindings between Facades and implementation classes, this provider will be then registered automatically in the app configuration.
- The namespace attribute represents the namespace for your application providers and where the FacadeServiceProvider file will be created, so in case you use a different folder you need to change that.
To create a new Facade for a particular class you can simply use the following command which accepts two inputs:
- Facade Name: The name of the Facade class that you would like to create.
- Class Path: the path to the class file that you would like to implement inside the app directory of your
application. e.g. ExampleController can be located by default at
Http\Controllers\ExampleController.php
php artisan make:facade FacadeName Custom/ImplementedClass.phpTo remove a Facade
php artisan remove:facade FacadeNameTo publish the facade service provider Note: You normally do not need to do this step because if the provider doesn't exist, it will be automatically published when you create a new Facade.
php artisan vendor:publish --tag=laravel-facade-providerPlease see the changelog for more information on what has changed recently.
composer testPlease see contributing.md for details and a todolist.
If you discover any security related issues, please email author email instead of using the issue tracker.
license. Please see the license file for more information.