ocramius/proxy-manager

A library providing utilities to generate, instantiate and generally operate with Object Proxies

Installs: 757 082

Dependents: 73

Stars: 430

Watchers: 28

Forks: 57

Open Issues: 24

Language: PHP

1.0.0 2014-12-12 10:59 UTC

README

This library aims at providing abstraction for generating various kinds of proxy classes.

ProxyManager

Build Status Code Coverage Scrutinizer Quality Score SensioLabsInsight Dependency Status Reference Status HHVM Status

Total Downloads Latest Stable Version Latest Unstable Version

Documentation

You can learn about the proxy pattern and how to use the ProxyManager on the online documentation.

Help/Support

Gitter

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.