PHP code example of lapistano / proxy-object

1. Go to this page and download the library: Download lapistano/proxy-object library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lapistano / proxy-object example snippets



$proxy = new \lapistano\ProxyObject\ProxyBuilder('myClass');

// generate and configure proxied object
$proxiedObject = $proxy
    ->setConstructorArgs(array('Argument1', 'Argument2'))
    ->setMethods(array('myMethod'))
    ->getProxy();

// invoke proxied method
$proxiedObject->myMethod();


$proxy = new \lapistano\ProxyObject\ProxyBuilder('myClass');

// generate and configure proxied object
$proxiedObject = $proxy
    ->setProperties(array('myMember'))
    ->getProxy();

// change content proxied member
$proxiedObject->myMember = 'another value';



$proxy = new \lapistano\ProxyObject\ProxyBuilder('myClass');

// generate and configure proxied object
$proxiedObject = $proxy
    ->disableOriginalConstructor()
    ->getProxy();

// change value of proxied member
$proxiedObject->myMember = 'another value';



/**
 * Provides a ProxyBuilder object.
 *
 * @param string $classname
 * @return lapistano\ProxyObject\ProxyBuilder
 */
protected function getProxyBuilder($classname) {
    return new \lapistano\ProxyObject\ProxyBuilder($classname);
}



// generate and configure proxied object
$proxiedObject = $this->getProxyBuilder('myClass')
    ->disableOriginalConstructor()
    ->getProxy();

// change value of proxied member
$proxiedObject->myMember = 'another value';