Download the PHP package lagdo/facades without Composer
On this page you can find all versions of the php package lagdo/facades. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lagdo/facades
More information about lagdo/facades
Files in lagdo/facades
Package facades
Short Description Base classes to implement service facades.
License BSD-3-Clause
Homepage https://github.com/lagdo/facades
Informations about the package facades
Base classes for service facades
This package provides base classes for service facades implementations.
The goal of the separation between this package and the framework related ones is to make the facades portable across different frameworks.
A service facade can be use without any change with various frameworks, provided that a package for this framework is available, or a PSR-11 container can be provided.
The following packages are currently available:
- Symfony: https://github.com/lagdo/symfony-facades
- Laravel: https://github.com/lagdo/laravel-facades
- CakePHP: https://github.com/lagdo/cake-facades
- Yii: https://github.com/lagdo/yii-facades
Facades definition
The Lagdo\Facades\AbstractFacade abstract class is the base class for user defined service facades.
If a given service doesn't need to be fetched from the container at each call, it can be saved in its facade class by using the Lagdo\Facades\ServiceInstance trait.
[!IMPORTANT] The
Lagdo\Facades\ServiceInstancetrait must be used in each service facade class, and not in a parent class. The same instance will be shared by all the classes inheriting the same base class using the trait, and the service facades will ot work as expected.
The service container will be called only once in the above example.
Container setup
The Lagdo\Facades\ContainerWrapper class gives access to the underlying container.
It needs to be provided with a PSR-11 container, which will be done by the framework specific packages, but can also be done by the developer in case a package is not available.
Provided facade and service
A default facade and a default service are provided for logging.
If the provided PSR-11 container already has a PSR-3 logger registered, then the Lagdo\Facades\Logger facade can be used.
A simple PSR-3 logger implementation is also provided.
It will return the local services, and revert to the already defined container for the other services.
Contribute
- Issue Tracker: github.com/lagdo/facades/issues
- Source Code: github.com/lagdo/facades
License
The package is licensed under the 3-Clause BSD license.
