Skip to content

guymers/php-dynamic-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A dynamic proxy generator for PHP.

Based on Javassist ProxyFactory

Usage

Config::set(["CACHE_DIRECTORY" => "/tmp/php-dynamic-proxy"]);

$class = new ReflectionClass("Class");
$methodOverrides = [
	new MethodHook {
		public function supports(ReflectionMethod $method) {
			return $method->getName() == "test";
		}

		public function invoke($proxy, ReflectionMethod $method, array $args) {
			// before original method

			$returnValue = $method->invokeArgs($proxy, $args);

			// after original method

			return $returnValue;
		}
	}
];

$proxy = ProxyFactory::create($class, $methodOverrides);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published