PHPackages                             danielgsims/staticproxy - 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. danielgsims/staticproxy

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

danielgsims/staticproxy
=======================

A thin proxy for static classes

1.0.2(10y ago)118.2k↓78.6%1PHP

Since Nov 18Pushed 10y ago1 watchersCompare

[ Source](https://github.com/danielgsims/staticproxy)[ Packagist](https://packagist.org/packages/danielgsims/staticproxy)[ RSS](/packages/danielgsims-staticproxy/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

StaticProxy
===========

[](#staticproxy)

StaticProxy is a thin class that acts as a proxy for calling static methods. You can use StaticProxy when you would like to inject an instance as opposed to calling static methods directly.

```

class Foo
{
    public static function doSomething()
    {
        return "do something";
    }
}

$s = new StaticProxy("Foo");
$s->doSomething();

```

\#Why?

Sometimes, you have a dependency that only functions with static methods:

```
class MyController
{
    public function index(Request $request)
    {
        Validator::validate($request);

        //do something
    }
}

```

Ideally, you would want to avoid static methods to make your code loosely coupled. You can use a proxy to make this happen.

```
class MyController
{
    private $validator;

    public function __construct(StaticProxy $validator)
    {
        $this->validator = $validator;
    }

    public function index(Request $request)
    {
        $this->validator->validate($request);
    }
}

```

This class is useful when you need to decouple static calls from your code but are unable to rewrite your dependencies, or do not have the means to create individual adapters.

\#Alias

In the above example, we had to typehint that we were using a static proxy, but that's not ideal. Instead, we can use the Aliaser to register aliases of StaticProxy.

```
class MyController
{
    private $validator;

    public function __construct(Acme\Validator $validator)
    {
        $this->validator = $validator;
    }

    public function index(Request $request)
    {
        $this->validator->validate($request);
    }
}

$a = new Aliaser;
$a->register("Acme\Validator");

$s = new StaticProxy("Foo");
$c = new MyController($s);

```

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity67

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

Every ~99 days

Total

5

Last Release

3847d ago

Major Versions

0.2.0 → 1.0.02014-11-19

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c96c41d0d99dc544740ceeb437dd1baa158fd0a8badc97936161821efbb07a0?d=identicon)[danielgsims](/maintainers/danielgsims)

---

Top Contributors

[![danielgsims](https://avatars.githubusercontent.com/u/695933?v=4)](https://github.com/danielgsims "danielgsims (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/danielgsims-staticproxy/health.svg)

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

###  Alternatives

[ayesh/composer-preload

Preload your sweet sweet code to opcache with a composer command, making your code faster to run

210133.1k](/packages/ayesh-composer-preload)[klaussilveira/gitter

Gitter allows you to interact in an object oriented manner with Git repositories.

19733.4k5](/packages/klaussilveira-gitter)[jandc/critical-css

Package wrapper and twig postprocessor class which uses the 'css from html extractor' library and twigwrapper to inject a document's head with critical css

3711.6k1](/packages/jandc-critical-css)[joegreen0991/config

Config component based on laravel's

233.3k](/packages/joegreen0991-config)

PHPackages © 2026

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