PHPackages                             tmont/phroxy - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tmont/phroxy

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tmont/phroxy
============

Proxy generator that supports interception of method calls

1.1.0(12y ago)0321WTFPLPHP

Since Jan 22Pushed 12y ago1 watchersCompare

[ Source](https://github.com/tmont/phroxy)[ Packagist](https://packagist.org/packages/tmont/phroxy)[ RSS](/packages/tmont-phroxy/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (2)Used By (1)

Phroxy
======

[](#phroxy)

[![Build Status](https://camo.githubusercontent.com/bbf37b29261bade8b63352c3c6d9a2ee341ea9c8a00306a49ff18b54a2ec87e6/68747470733a2f2f7472617669732d63692e6f72672f746d6f6e742f7068726f78792e706e67)](https://travis-ci.org/tmont/phroxy)

**Phroxy** is a proxy generator. It's probably useful. You can use it to create a mock object, or to create a proxy and intercept methods on that proxy.

Installation
------------

[](#installation)

User composer:

```
{
  "require": {
    "tmont/phroxy": "1.1.x"
  }
}
```

Usage
-----

[](#usage)

I don't feel like writing documentation, so take a look at the [unit tests](./tests/ProxyTest.php). There are examples of basic proxying as well as advanced method interception.

The basic gist is:

```
use Tmont\Phroxy\Interceptor;
use Tmont\Phroxy\InterceptorCache;
use Tmont\Phroxy\InterceptionContext;
use ReflectionClass;

class ReturnBeforeCallInterceptor implements Interceptor {
	public function onBeforeMethodCall(InterceptionContext $context) {
		$context->setReturnValue('oh hai!');
	}

	public function onAfterMethodCall(InterceptionContext $context) {}
}

class MyClass {
	public function hello() {
		return 'hello';
	}
}

$interceptor = new ReturnBeforeCallInterceptor();
InterceptorCache::registerInterceptor($interceptor, function($x) { return true; });

$proxy = $this->builder->build(new ReflectionClass('MyClass'));
$proxy->hello(); // "oh hai!"
```

Development
-----------

[](#development)

```
git clone git@github.com:tmont/phroxy.git
cd phroxy
composer install
vendor/bin/phpunit
```

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4535d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/188562?v=4)[tmont](/maintainers/tmont)[@tmont](https://github.com/tmont)

---

Top Contributors

[![tmont](https://avatars.githubusercontent.com/u/188562?v=4)](https://github.com/tmont "tmont (6 commits)")

---

Tags

proxyinterceptionintercept

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tmont-phroxy/health.svg)

```
[![Health](https://phpackages.com/badges/tmont-phroxy/health.svg)](https://phpackages.com/packages/tmont-phroxy)
```

###  Alternatives

[fideloper/proxy

Set trusted proxies for Laravel

7.3k175.9M561](/packages/fideloper-proxy)[ocramius/proxy-manager

A library providing utilities to generate, instantiate and generally operate with Object Proxies

5.0k82.9M238](/packages/ocramius-proxy-manager)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k397.4M682](/packages/symfony-var-exporter)[friendsofphp/proxy-manager-lts

Adding support for a wider range of PHP versions to ocramius/proxy-manager

1.2k144.7M129](/packages/friendsofphp-proxy-manager-lts)[vkartaviy/retry

The library for repeatable and retryable operations

29229.5k2](/packages/vkartaviy-retry)[astrotomic/php-conditional-proxy

This package provides a trait and class to allow calling methods based on a condition without breaking the method chain.

31166.8k7](/packages/astrotomic-php-conditional-proxy)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
