Skip to content

Instantly share code, notes, and snippets.

@jeremylivingston
Created August 26, 2013 13:56
Show Gist options
  • Save jeremylivingston/6341673 to your computer and use it in GitHub Desktop.
Save jeremylivingston/6341673 to your computer and use it in GitHub Desktop.
A basic example of how a core PHP class like SoapClient cannot be created as a proxy.
<?php
$config = new \ProxyManager\Configuration(); // customize this if needed for production
$factory = new \ProxyManager\Factory\LazyLoadingValueHolderFactory($config);
$proxy = $factory->createProxy(
'SoapClient',
function (& $wrappedObject, $proxy, $method, $parameters, & $initializer) {
$wrappedObject = new \SoapClient('http://www.blah.com'); // instantiation logic here
$initializer = null; // turning off further lazy initialization
return true;
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment