Laravel Facade
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\Facades
to define the facade accessor. - A Facade service provider
App\Providers\FacadeServiceProvider.php
is created/edited to bind your implementation class to the facade accessor. - The
FacadeServiceProvider
is registered in your app configuration file (config\app.php
).
Installation
Via Composer
composer require hmones/laravel-facade --dev
Configuration
To publish the package configuration
php artisan vendor:publish --tag=laravel-facade-config
The configuration contains the following values:
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.
Usage
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.php
To remove a Facade
php artisan remove:facade FacadeName
To 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-provider
Change log
Please see the changelog for more information on what has changed recently.
Testing
composer test
Contributing
Please see contributing.md for details and a todolist.
Security
If you discover any security related issues, please email author email instead of using the issue tracker.
Credits
License
license. Please see the license file for more information.