🌈 OOP Proxy wrappers utilities - generates and manages proxies of your objects
Latest commit cce5477 Jan 4, 2017 @Ocramius committed on GitHub Merge pull request #360 from Slamdunk/patch-1
README.md fix FQCN usage
Failed to load latest commit information.
doc-template Linking changelog in the docs footer Jan 28, 2016
docs Fix typo in ghost objects lazy loading code example Oct 19, 2016
examples #272 - Example of ghost object skipped properties Jan 28, 2016
html-docs Redirecting to new documentation URIs in `html-docs` (to be removed i… Mar 19, 2015
src/ProxyManager Deprecating `FileNotWritableException#fromNonWritableLocation()` Nov 20, 2016
tests Revert "Removing tests for the unused `ProxyManager\Exception\FileNot… Nov 20, 2016
.gitattributes Skipping files/directories that are not needed in deployed versions o… Dec 14, 2014
.gitignore #274 - couscous build dir should be ignored Jan 22, 2016
.scrutinizer.yml Remove php 7.x from allowed failure Apr 8, 2015
.travis.coverage.sh Coverage is to now be completed on PHP 7.1 Nov 19, 2016
.travis.install.sh No need to `--prefer-source` on installations anymore Nov 19, 2016
.travis.yml Adding PHP nightly to the mix, since it will allow eager discovery of… Nov 30, 2016
CHANGELOG.md ProxyManager 2.1.0 release notes Nov 30, 2016
CONTRIBUTING.md Insert metainfo title on markdown contents Mar 20, 2015
LICENSE EOF EOL Sep 23, 2014
README.md README.md fix FQCN usage Jan 4, 2017
STABILITY.md extend date for bug fixes and security fixes for 2.0.x version Jan 3, 2017
UPGRADE.md #272 - PHP 4 constructors are no longer supported Jan 28, 2016
composer.json Requiring humbug for mutation testing Nov 20, 2016
couscous.yml Correcting couscous base directory Mar 19, 2015
humbug.json.dist Added humbug configuration Nov 20, 2016
phpbench.json Aggregate report is usually what is needed Jul 1, 2016
phpdox.xml.dist EOF EOL fixes Sep 23, 2014
phpmd.xml.dist EOF EOL fixes Sep 23, 2014
phpunit.xml.dist Fix: Use all the columns Aug 22, 2015
proxy-manager.png Including rasterized version of the logo (renders on github) Nov 9, 2013
proxy-manager.svg Adding logo Nov 9, 2013


Proxy Manager

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


Build Status Code Coverage Scrutinizer Quality Score SensioLabsInsight Dependency Status Reference Status HHVM 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.