51 lines
2.7 KiB
Markdown
51 lines
2.7 KiB
Markdown
# Proxy Manager
|
|
|
|
This library aims at providing abstraction for generating various kinds of [proxy classes](http://marco-pivetta.com/proxy-pattern-in-php/).
|
|
|
|

|
|
|
|
[](https://travis-ci.org/Ocramius/ProxyManager)
|
|
[](https://scrutinizer-ci.com/g/Ocramius/ProxyManager/)
|
|
[](https://scrutinizer-ci.com/g/Ocramius/ProxyManager/)
|
|
[](https://insight.sensiolabs.com/projects/69fe5f97-b1c8-4ddd-93ce-900b8b788cf2)
|
|
[](https://www.versioneye.com/package/php--ocramius--proxy-manager)
|
|
[](https://www.versioneye.com/php/ocramius:proxy-manager/references)
|
|
[](http://hhvm.h4cc.de/package/ocramius/proxy-manager)
|
|
|
|
[](https://packagist.org/packages/ocramius/proxy-manager)
|
|
[](https://packagist.org/packages/ocramius/proxy-manager)
|
|
[](https://packagist.org/packages/ocramius/proxy-manager)
|
|
|
|
|
|
## Documentation
|
|
|
|
You can learn about the proxy pattern and how to use the **ProxyManager** on the [online documentation](http://ocramius.github.io/ProxyManager).
|
|
|
|
## Installation
|
|
|
|
The suggested installation method is via [composer](https://getcomposer.org/):
|
|
|
|
```sh
|
|
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*
|
|
|
|
```php
|
|
$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](http://ocramius.github.io/ProxyManager) for more supported proxy types and examples.
|