Download the PHP package lhsazevedo/restatic without Composer
On this page you can find all versions of the php package lhsazevedo/restatic. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download lhsazevedo/restatic
More information about lhsazevedo/restatic
Files in lhsazevedo/restatic
Package restatic
Short Description Laravel like facades por PSR11 containers
License MIT
Informations about the package restatic
ReStatic
Laravel like Facades (static proxies) for PSR11 containers.
Requirements
PHP 7.2+ or 8+
Usage
Setup Container
Create Static Proxies
Setup Facades
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
- FAQ
- Demo application
Inspiration
ReStatic is based on the awesome package XStatic created by Jeremy Lindblom.
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