Proxy Manager
This library aims at providing abstraction for generating various kinds of proxy classes.
Documentation
You can learn about the proxy pattern and how to use the ProxyManager on the online documentation.
Installation
The suggested installation method is via composer:
php composer.phar require ocramius/proxy-manager:1.0.*
Proxy example
Here's how you build a lazy loadable object with ProxyManager using a Virtual Proxy
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory();
$proxy = $factory->createProxy(
'MyApp\HeavyComplexObject',
function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
$wrappedObject = new HeavyComplexObject(); // instantiation logic here
$initializer = null; // turning off further lazy initialization
}
);
$proxy->doFoo();
See the online documentation for more supported proxy types and examples.