PHPackages                             lhsazevedo/restatic - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. lhsazevedo/restatic

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

lhsazevedo/restatic
===================

Laravel like facades por PSR11 containers

v3.0.1(5y ago)73492[1 PRs](https://github.com/lhsazevedo/restatic/pulls)1MITPHPPHP ^7.2|^8

Since Sep 25Pushed 5y ago1 watchersCompare

[ Source](https://github.com/lhsazevedo/restatic)[ Packagist](https://packagist.org/packages/lhsazevedo/restatic)[ RSS](/packages/lhsazevedo-restatic/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (3)Versions (14)Used By (1)

ReStatic
========

[](#restatic)

[![Build Status](https://camo.githubusercontent.com/28cff1a3c795a802af05da5031865b9815133c51eaeee65e71475fd5cf172784/68747470733a2f2f7472617669732d63692e6f72672f6c6873617a657665646f2f72657374617469632e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lhsazevedo/restatic)

Laravel like Facades (static proxies) for PSR11 containers.

```
class HomeController
{
    public function __invoke()
    {
        // It just works!
        return View::render('home.index', [
            'articles' => DB::query('SELECT * FROM articles')
        ]);
    }
}
```

Requirements
------------

[](#requirements)

PHP 7.2+ or 8+

Usage
-----

[](#usage)

Setup Container

```
$container = new \DI\Container();
$container->set('db', function () {
    return new PDO('mysql:dbname=testdb;host=127.0.0.1', 'dbuser', 'dbpass');
});
```

Create Static Proxies

```
// app/Facades/DB.php

class DB extends StaticProxy
{
    public static function getInstanceIdentifier()
    {
        return 'db';
    }
}
```

Setup Facades

```
$proxyManager = new ProxyManager($container);
$proxyManager->addProxy('DB', DB::class);
$proxyManager->addProxy('View', View::class);
$proxyManager->enable(ProxyManager::ROOT_NAMESPACE_ANY);
```

Concepts
--------

[](#concepts)

- **Static Proxy** – Static class that proxies static method calls to instance methods on its *Proxy Subject*.
- **Proxy Subject (Instance)** – An object instance, stored in a *Container*, that is linked to a *Static Proxy*.
- **Proxy Manager** – Mediating object used to associate *Static Proxies* to an *Alias Loader* and *Container*.
- **Alias** – A memorable class name used as an alias to a fully-qualified class name of a *Static Proxy* class.
- **Alias Loader** – Maintainer of the associations between *Aliases* and *Static Proxies*. It is injected into the autoloader stack to handle Aliases as they are referenced.
- **Container** – A IoC container (e.g., a Service Locator or DIC) that provides the *Proxy Subject* instances. It must implement the PSR-11 stardard's `ContainerInterface`.
- **Instance Identifier** – An identifier used to fetch a *Proxy Subject* from a *Container*. Each *Static Proxy* must specify the Instance Identifier needed to get its Proxy Subject.
- **Root Namespace** – The namespace that an *Alias* can be referenced in. This can be configured as the global namespace (default), a specific namespace, or *any* namespace (i.e., the Alias works from any namespace).

More
----

[](#more)

- [FAQ](docs/faq.md)
- [Demo application](docs/slim-demo.md)

Inspiration
-----------

[](#inspiration)

ReStatic is based on the awesome package XStatic created by [Jeremy Lindblom](https://twitter.com/jeremeamia).

Disclaimer
----------

[](#disclaimer)

> I would not consider myself to be *for* or *against* the use of static proxy interfaces (or Laravel's "Facades"), but I do think it is a fascinating and unique idea, and that it is very cool that you can write code this way and still have it work and be testable. I am curious to see if developers, especially library and framework developers, find ways to use, *but not require*, these static proxy interfaces in order to make their projects appeal to a wider range of PHP developers.
> — [Jeremy Lindblom](https://twitter.com/jeremeamia)

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity65

Established project with proven stability

 Bus Factor1

Top contributor holds 63.2% 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 ~241 days

Recently: every ~39 days

Total

12

Last Release

1959d ago

Major Versions

0.2.0 → 1.0.0-rc.12014-03-27

1.0.2 → v2.0.0-alpha12020-07-23

v2.0.0 → v3.0.02020-12-27

PHP version history (3 changes)0.1.0PHP &gt;=5.3.3

v2.0.0-alpha1PHP ^7.2

v3.0.1PHP ^7.2|^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/011e68c7a2cf863af3a150252c213425d2cc638eec08afc51280bdfddf51732b?d=identicon)[lhs\_azevedo](/maintainers/lhs_azevedo)

---

Top Contributors

[![lhsazevedo](https://avatars.githubusercontent.com/u/7695608?v=4)](https://github.com/lhsazevedo "lhsazevedo (36 commits)")[![jeremeamia](https://avatars.githubusercontent.com/u/107867?v=4)](https://github.com/jeremeamia "jeremeamia (17 commits)")[![dlundgren](https://avatars.githubusercontent.com/u/1322393?v=4)](https://github.com/dlundgren "dlundgren (3 commits)")[![pherrymason](https://avatars.githubusercontent.com/u/1103977?v=4)](https://github.com/pherrymason "pherrymason (1 commits)")

---

Tags

facadespsr-11static-proxycontainerproxyinterfacestaticfacadefacadesservice locatorstatic proxy

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/lhsazevedo-restatic/health.svg)

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

###  Alternatives

[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)[php-di/php-di

The dependency injection container for humans

2.8k48.9M991](/packages/php-di-php-di)[acclimate/container

Provides adapters for various third-party service containers.

219390.6k15](/packages/acclimate-container)[league/tactician-container

Tactician integration for any container implementing PSR-11

7710.1M23](/packages/league-tactician-container)[mrclay/props-dic

Props is a simple DI container that allows retrieving values via custom property and method names

3611.7M3](/packages/mrclay-props-dic)

PHPackages © 2026

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