{"id":18794570,"url":"https://github.com/effectra/facade","last_synced_at":"2025-12-29T18:30:14.242Z","repository":{"id":169876318,"uuid":"645959649","full_name":"effectra/facade","owner":"effectra","description":"The Facade class is a utility class that provides a simplified interface to access classes or services in your PHP applications.","archived":false,"fork":false,"pushed_at":"2023-05-26T21:41:45.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-29T16:34:09.286Z","etag":null,"topics":["facade","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/effectra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-26T21:29:48.000Z","updated_at":"2023-05-26T21:39:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"04a62944-2833-42dd-8c5d-6ed817930074","html_url":"https://github.com/effectra/facade","commit_stats":null,"previous_names":["effectra/facade"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Ffacade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Ffacade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Ffacade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/effectra%2Ffacade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/effectra","download_url":"https://codeload.github.com/effectra/facade/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718733,"owners_count":19685806,"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":["facade","php"],"created_at":"2024-11-07T21:29:48.645Z","updated_at":"2025-12-29T18:30:14.184Z","avatar_url":"https://github.com/effectra.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Facade Class\n\nThe `Facade` class is a utility class that provides a simplified interface to access classes or services in your PHP applications.\n\n## Installation\n\nThe `Facade` class is a standalone class and doesn't require any installation. You can simply include the class file in your project.\n\n```php\ncomposer require effectra/facade\n```\n\n## Usage\n\nTo use the `Facade` class, follow these steps:\n\n1. Extend the `Facade` class with your custom facade class.\n2. Implement the `getFacadeAccessor()` method in your custom facade class.\n3. Optionally, set the resolved instance or container using the `setResolvedInstance()` or `setContainer()` method respectively.\n4. Access the methods of the underlying class or service using the static methods of your custom facade class.\n\nHere's an example:\n\n```php\nuse Effectra\\Facade;\n\nclass MyFacade extends Facade\n{\n    protected static function getFacadeAccessor()\n    {\n        return MyService::class;\n    }\n}\n\n// Usage\nMyFacade::setResolvedInstance(new MyService());\nMyFacade::someMethod();\n```\n\nIn this example, we've created a custom facade class `MyFacade` by extending the `Facade` class. The `getFacadeAccessor()` method in `MyFacade` returns the class name of `MyService` that we want to access using the facade.\n\nBy setting the resolved instance using `setResolvedInstance()`, we directly provide an instance of `MyService` to the facade. This allows us to access the methods of `MyService` using the static methods of `MyFacade`.\n\nYou can also use a container instead of setting the resolved instance directly. To do so, create a container, bind the class name to a key in the container, and set the container using `setContainer()`.\n\n```php\nuse Effectra\\Facade;\nuse Effectra\\Container\\Container;\n\nclass MyFacade extends Facade\n{\n    protected static function getFacadeAccessor()\n    {\n        return 'myService';\n    }\n}\n\n// Usage\n$container = new Container();\n$container-\u003ebind('myService', MyService::class);\n\nMyFacade::setContainer($container);\nMyFacade::someMethod();\n```\n\nIn this example, we've used a simple `Container` class to bind the class name of `MyService` to the key `'myService'`. By setting the container using `setContainer()`, the `Facade` class resolves the instance from the container when the static method is called.\n\nMake sure to replace `'MyService'` and `'someMethod()'` with the actual class and method names you're using in your application.\n\n## Contributing\n\nContributions are welcome! If you find any issues or would like to add new features or improvements, please open an issue or submit a pull request.\n\nBefore contributing, please make sure to review the [contribution guidelines](CONTRIBUTING.md).\n\n## License\n\nThis class is open-source and available under the [MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Ffacade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feffectra%2Ffacade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feffectra%2Ffacade/lists"}