PHPackages                             anax/proxy - 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. [Framework](/categories/framework)
4. /
5. anax/proxy

ActiveLibrary[Framework](/categories/framework)

anax/proxy
==========

Anax Proxy module, for static access to di service container.

v1.0.2(7y ago)01.7k↓90%1MITMakefilePHP ^7.2

Since Nov 20Pushed 7y ago1 watchersCompare

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

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

Anax Proxy
==========

[](#anax-proxy)

[![Latest Stable Version](https://camo.githubusercontent.com/2d062e0899cfb8d0975579dfd0483c04da625590cd1a8e3af10aa2653b22a637/68747470733a2f2f706f7365722e707567782e6f72672f616e61782f70726f78792f762f737461626c65)](https://packagist.org/packages/anax/proxy)[![Join the chat at https://gitter.im/canax/proxy](https://camo.githubusercontent.com/c7d0212eaae0676c9fff4370fda65c5df8650b32646de5a043e5ba1a90afdfad/68747470733a2f2f6261646765732e6769747465722e696d2f63616e61782f70726f78792e737667)](https://gitter.im/canax/proxy?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

[![Build Status](https://camo.githubusercontent.com/5d598a552a3149d9cfed08f67d46a24cf4314ceda936c7f8b14252dacd495828/68747470733a2f2f7472617669732d63692e6f72672f63616e61782f70726f78792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/canax/proxy)[![CircleCI](https://camo.githubusercontent.com/be4f804ae89d64527e403a18009f09ee359a26a802fc9c469fbc95b9ec6e656e/68747470733a2f2f636972636c6563692e636f6d2f67682f63616e61782f70726f78792e7376673f7374796c653d737667)](https://circleci.com/gh/canax/proxy)

[![Build Status](https://camo.githubusercontent.com/e5b331d3d14d0baf5c48dbf6e056c9146a7a8c482d3e67c5d95f3bea34720836/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f70726f78792f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/proxy/build-status/master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/0aedeaaae15cd820331ebcca9342a0895a227f9814193a02ff7ea68628115586/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f70726f78792f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/proxy/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cb45117768cc5dc7130d29cf8bbd08ed034e056ff7e3de302e67c1f5c0d2b21f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f63616e61782f70726f78792f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/canax/proxy/?branch=master)

[![Maintainability](https://camo.githubusercontent.com/17400f586bb02b0570e8b572e0703383d6c7511686aec138847f1ac22c88e0ab/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f38373035653962633061353937653664666239612f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/canax/proxy/maintainability)[![Codacy Badge](https://camo.githubusercontent.com/1992a7cb3efd75faeb63e4644abe3536f9a9eb64a0c0defa705b093770a18815/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6333643630663333633062393437613361663132373738386538303062343032)](https://www.codacy.com/app/mosbth/proxy?utm_source=github.com&utm_medium=referral&utm_content=canax/proxy&utm_campaign=Badge_Grade)

Anax proxy is a module for static proxy to access framework resources, services, that are available in `$di` service container.

The basic idea is to allow static access like this `Session::start()`. You can see it as a wrapper above the ordinary way using `$di->get("session")->start()`. It is syntactic sugar.

You can compare it to the implementation of Laravel Facade.

Table of content
----------------

[](#table-of-content)

- [Install](#install)
- [Development](#development)
- [Init the proxy factory](#Init-the-proxy-factory)
- [Use services through the proxy](#Use-services-through-the-proxy)
- [Related design patterns](#Related-design-patterns)
- [Dependency](#Dependency)
- [License](#License)

You can also read this [documentation online](https://canax.github.io/proxy/).

Install
-------

[](#install)

You can install the module from [`anax/proxy` on Packagist](https://packagist.org/packages/anax/proxy) using composer.

```
composer require anax/proxy

```

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

[](#development)

To work as a developer you clone the repo and install the local environment through make. Then you can run the unit tests.

```
make install
make test

```

Init the proxy factory
----------------------

[](#init-the-proxy-factory)

You start by initiating the proxy factory in the frontcontroller `index.php`.

```
use Anax\Proxy\ProxyDIFactory;

// Add all framework services to $di
$di = new Anax\DI\DIFactoryConfig();
$di->loadServices(ANAX_INSTALL_PATH . "/config/di");

// Add anax/proxy access to $id, if available
ProxyDIFactory::init($di);
```

Or like this to take into account if the module is installed or not.

```
// Add anax/proxy access to $id, if available
if (class_exists("\Anax\Proxy\ProxyDIFactory")) {
    \Anax\Proxy\ProxyDIFactory::init($di);
}
```

The service container `$di` is injected and an autoloader is created to catch and dynamic create classes for the proxy class to map the service in `$di`.

Use services through the proxy
------------------------------

[](#use-services-through-the-proxy)

You start by defining the proxy service class through its service name, like this.

```
use \Anax\Proxy\DI\Db;
```

You can then use it through static access `Db::connect()` which behind the scenes translates to `$di->get("db")->connect()`.

This is how it can be used with a route.

```
use \Anax\Proxy\DI\Db;
use \Anax\Proxy\DI\Router;
use \Anax\Proxy\DI\View;
use \Anax\Proxy\DI\Page;

/**
 * Show all movies.
 */
Router::get("movie", function () {
    $data = [
        "title"  => "Movie database | oophp",
    ];

    Db::connect();

    $sql = "SELECT * FROM movie;";
    $res = Db::executeFetchAll($sql);

    $data["res"] = $res;

    View::add("movie/index", $data);
    Page::render($data);
});
```

Here is the same route implemented, with `$app` style programming and dependency to the (globaly) scoped variable `$app` which is a front for `$di`.

```
/**
 * Show all movies.
 */
$app->router->get("movie", function () use ($app) {
    $data = [
        "title"  => "Movie database | oophp",
    ];

    $app->db->connect();

    $sql = "SELECT * FROM movie;";
    $res = $app->db->executeFetchAll($sql);

    $data["res"] = $res;

    $app->view->add("movie/index", $data);
    $app->page->render($data);
});
```

Above example uses `$app` which itself does a `$di->get("service")` behind the scene.

So, it is a matter of syntactic sugar, a layer of user friendliness you might approve of, or not.

Related design patterns
-----------------------

[](#related-design-patterns)

Laravel have an implementation as Laravel Facade. This might indicate they relate to the design pattern [`Facade design pattern`](https://en.wikipedia.org/wiki/Facade_pattern).

People have argued that the implementation is more of the design pattern [`Proxy design pattern`](https://en.wikipedia.org/wiki/Proxy_pattern).

People have also argued that it is an implementation of the design pattern [`Singleton design pattern`](https://en.wikipedia.org/wiki/Singleton_pattern).

Dependency
----------

[](#dependency)

Using psr11 through `psr/container`.

License
-------

[](#license)

This software carries a MIT license. See [LICENSE.txt](LICENSE.txt) for details.

```
 .
..:  Copyright (c) 2018 Mikael Roos, mos@dbwebb.se

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

2771d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4cac244120f54c02a4fb3186b91323f3f0805dd9daefd0babeb4a82a19232faf?d=identicon)[mikael\_roos](/maintainers/mikael_roos)

---

Top Contributors

[![mosbth](https://avatars.githubusercontent.com/u/169550?v=4)](https://github.com/mosbth "mosbth (13 commits)")

---

Tags

frameworkproxy patternanaxFacade Pattern

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/anax-proxy/health.svg)

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

###  Alternatives

[pestphp/pest-plugin-stressless

Stressless plugin for Pest

68943.9k18](/packages/pestphp-pest-plugin-stressless)

PHPackages © 2026

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