1.0.0 2022-04-25 23:46 UTC

This package is auto-updated.

Last update: 2024-03-26 03:48:15 UTC


Build Status SilverStripe supported module

Dynamically scaffold proxy classes that actually extend the class being proxied, allowing them to be used in type-strict applications.

No it's not prophecy because this is designed for partial proxies, not testing.


composer require tractorcow/classproxy


// Create a proxy creator
$proxy = ProxyFactory::create(DataBase::class)
    ->addMethod('connect', function ($args, $next) use ($logger) {
        $logger->log("Connecting to server " . $args[0]['server'];
        return $next(...$args);
// Generate instance of our proxy
$instance = $proxy->instance();
assert($instance instanceof Database); // Yep!

// Connects to underlying database, logging the call
    'server' => 'localhost',
    'user' => 'root'