{"id":27745689,"url":"https://github.com/lhsazevedo/restatic","last_synced_at":"2025-04-28T19:56:47.716Z","repository":{"id":55496340,"uuid":"168253642","full_name":"lhsazevedo/restatic","owner":"lhsazevedo","description":"Laravel like facades for PSR11 containers ","archived":false,"fork":false,"pushed_at":"2020-12-27T15:32:45.000Z","size":66,"stargazers_count":7,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T19:56:43.282Z","etag":null,"topics":["facades","psr-11","static-proxy"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lhsazevedo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-01-30T00:47:05.000Z","updated_at":"2024-02-26T11:22:30.000Z","dependencies_parsed_at":"2022-08-15T01:50:14.669Z","dependency_job_id":null,"html_url":"https://github.com/lhsazevedo/restatic","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhsazevedo%2Frestatic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhsazevedo%2Frestatic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhsazevedo%2Frestatic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lhsazevedo%2Frestatic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lhsazevedo","download_url":"https://codeload.github.com/lhsazevedo/restatic/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251380914,"owners_count":21580338,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["facades","psr-11","static-proxy"],"created_at":"2025-04-28T19:56:47.286Z","updated_at":"2025-04-28T19:56:47.708Z","avatar_url":"https://github.com/lhsazevedo.png","language":"PHP","readme":"# ReStatic\n\n[![Build Status](https://travis-ci.org/lhsazevedo/restatic.svg?branch=master)](https://travis-ci.org/lhsazevedo/restatic)\n\nLaravel like Facades (static proxies) for PSR11 containers.\n\n\n```php\nclass HomeController\n{\n    public function __invoke()\n    {\n        // It just works!\n        return View::render('home.index', [\n            'articles' =\u003e DB::query('SELECT * FROM articles')\n        ]);\n    }\n}\n```\n\n## Requirements\nPHP 7.2+ or 8+\n\n## Usage\n\nSetup Container\n```php\n$container = new \\DI\\Container();\n$container-\u003eset('db', function () {\n    return new PDO('mysql:dbname=testdb;host=127.0.0.1', 'dbuser', 'dbpass');\n});\n```\n\nCreate Static Proxies\n```php\n// app/Facades/DB.php\n\nclass DB extends StaticProxy\n{\n    public static function getInstanceIdentifier()\n    {\n        return 'db';\n    }\n}\n```\n\nSetup Facades\n```php\n$proxyManager = new ProxyManager($container);\n$proxyManager-\u003eaddProxy('DB', DB::class);\n$proxyManager-\u003eaddProxy('View', View::class);\n$proxyManager-\u003eenable(ProxyManager::ROOT_NAMESPACE_ANY);\n```\n\n## Concepts\n\n* **Static Proxy** – Static class that proxies static method calls to instance methods on its *Proxy Subject*.\n* **Proxy Subject (Instance)** – An object instance, stored in a *Container*, that is linked to a *Static Proxy*.\n* **Proxy Manager** – Mediating object used to associate *Static Proxies* to an *Alias Loader* and *Container*.\n* **Alias** – A memorable class name used as an alias to a fully-qualified class name of a *Static Proxy* class.\n* **Alias Loader** – Maintainer of the associations between *Aliases* and *Static Proxies*. It is injected into the\n  autoloader stack to handle Aliases as they are referenced.\n* **Container** – A IoC container (e.g., a Service Locator or DIC) that provides the *Proxy Subject* instances. It must\n  implement the PSR-11 stardard's `ContainerInterface`.\n* **Instance Identifier** – An identifier used to fetch a *Proxy Subject* from a *Container*. Each *Static Proxy* must\n  specify the Instance Identifier needed to get its Proxy Subject.\n* **Root Namespace** – The namespace that an *Alias* can be referenced in. This can be configured as the global\n  namespace (default), a specific namespace, or *any* namespace (i.e., the Alias works from any namespace).\n\n## More\n- [FAQ](docs/faq.md)\n- [Demo application](docs/slim-demo.md)\n\n## Inspiration\nReStatic is based on the awesome package XStatic created by [Jeremy Lindblom](https://twitter.com/jeremeamia).\n\n## Disclaimer\n\n\u003e I would not consider myself to be *for* or *against* the use of static proxy interfaces (or Laravel's \"Facades\"), but I\n\u003e 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\n\u003e it work and be testable. I am curious to see if developers, especially library and framework developers, find ways to\n\u003e use, *but not require*, these static proxy interfaces in order to make their projects appeal to a wider range of PHP\n\u003e developers.  \n\u003e — [Jeremy Lindblom](https://twitter.com/jeremeamia)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhsazevedo%2Frestatic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flhsazevedo%2Frestatic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flhsazevedo%2Frestatic/lists"}