indragunawan / facade-bundle
Support Facades for Symfony services.
Installs: 11 854
Dependents: 0
Suggesters: 0
Security: 0
Stars: 17
Watchers: 4
Forks: 2
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.1.3
- psr/container: ^1.0
- symfony/dependency-injection: ^3.4 || ^4.0 || ^5.0
Requires (Dev)
- phpunit/phpunit: ^7.5.2 || ^8.0
- symfony/framework-bundle: ^3.4 || ^4.0 || ^5.0
This package is auto-updated.
Last update: 2024-11-13 16:17:22 UTC
README
Support Facades for Symfony service.
thanks to:
- Service Locator - for making all the referenced facade service lazy-loaded.
- Service Autoconfiguration - for making all classes that extend
Indragunawan\FacadeBundle\AbstractFacade
class automatically tagged as facade.
Documentation
Installation
If your project already uses Symfony Flex, execute this command to download, register and configure the bundle automatically:
composer require indragunawan/facade-bundle
If you install without using Symfony Flex, first add the bundle by using composer then enable the bundle by adding new Indragunawan\FacadeBundle\IndragunawanFacadeBundle()
to the list of registered bundles in the app/AppKernel.php file of your project
Creating Facade
To create a facade create a class that extends base Indragunawan\FacadeBundle\AbstractFacade
class and implement the getFacadeAccessor
method that returns the service id
, support private and public service.
<?php namespace App\Facades; use Indragunawan\FacadeBundle\AbstractFacade; class Foo extends AbstractFacade { protected static function getFacadeAccessor() { return 'App\Service\Foo'; // service id - supports private and public service. } }
Now the facade now ready. Simply import the facade namespace. When you call any static method on the Foo
facade, then it will resolve the service that you define in getFacadeAccessor
method and call the requested method from the service.
License
This bundle is under the MIT license. See the complete license