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

Installs: 19 247 125

Dependents: 269

Suggesters: 32

Stars: 1 981

Watchers: 46

Forks: 114

Open Issues: 44

2.2.2 2018-09-27 13:45 UTC


This library aims to provide abstraction for generating various kinds of proxy classes.


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

Total Downloads Latest Stable Version Latest Unstable Version


You can learn about the proxy pattern and how to use the ProxyManager in the docs, which are also compiled to HTML.




The suggested installation method is via composer:

php composer.phar require ocramius/proxy-manager

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(
    function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
        $wrappedObject = new \MyApp\HeavyComplexObject(); // instantiation logic here
        $initializer   = null; // turning off further lazy initialization


See the online documentation for more supported proxy types and examples.