Download the PHP package golossus/php-lazy-proxy-loading without Composer
On this page you can find all versions of the php package golossus/php-lazy-proxy-loading. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-lazy-proxy-loading
php-lazy-proxy-loading is a package which tries to ease in the process of loading PHP classes (or services) by using a lazy strategy. This comes in handy when working with Dependency Injection containers which are in charge of building the services of many applications.
This package does so by providing a Proxy Class Factory which can create a Proxy Class for any PHP Class or service. Real service is only built when the service is really needed, that is at first call of its public methods.
It is specially interesting to combine this library with Laravel framework, given the fact that currently there's no a bult-in strategy in this framework to provide lazy-loading of services. We started this library in order to solve Dependency Injection issues we had using Laravel that could be solver very easily by lazy-loading some services.
Installation
Usage
Basic usage example:
It's worth noting in the above example $myClassProxy
extends MyClass
type, and it serves as an adapter behaving as
the underlying service, so it can be injected seamlessly as the real service. Final service will be built once we call
any of its public methods by using the callback function passed as second argument of the ProxyClassFactory::create
method.
Laravel
For Laravel framework, this package provides a special trait to seamlessly use the proxy factory with its Dependency
Injection container. You can use
the trait in any Laravel service provider and define any service as lazy
:
Community
- Join our Slack to meet the community and get support.
- Follow us on GitHub.
- Read our Code of Conduct.
Contributing
This is an Open Source project. The Golossus team wants to enable it to be community-driven and open to contributing documentation.
Security Issues
If you discover a security vulnerability, please follow our disclosure procedure.
About Us
This package development is led by the Golossus Team contributors.