{"id":24016372,"url":"https://github.com/decodelabs/veneer","last_synced_at":"2025-07-30T00:33:25.486Z","repository":{"id":35109764,"uuid":"207678979","full_name":"decodelabs/veneer","owner":"decodelabs","description":"Automated static frontages for PHP","archived":false,"fork":false,"pushed_at":"2025-06-06T12:58:42.000Z","size":227,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-07-08T12:03:43.464Z","etag":null,"topics":["facade","frontage","php"],"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/decodelabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2019-09-10T23:08:20.000Z","updated_at":"2025-06-06T12:58:44.000Z","dependencies_parsed_at":"2023-02-15T07:31:14.555Z","dependency_job_id":"72290b82-97af-45be-a879-8d15fd3284fb","html_url":"https://github.com/decodelabs/veneer","commit_stats":{"total_commits":188,"total_committers":2,"mean_commits":94.0,"dds":0.0478723404255319,"last_synced_commit":"61344d9ff0aea2298784978132cda5602d65f4fa"},"previous_names":[],"tags_count":73,"template":false,"template_full_name":null,"purl":"pkg:github/decodelabs/veneer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fveneer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fveneer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fveneer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fveneer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decodelabs","download_url":"https://codeload.github.com/decodelabs/veneer/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decodelabs%2Fveneer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267785745,"owners_count":24144120,"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","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","frontage","php"],"created_at":"2025-01-08T08:49:16.652Z","updated_at":"2025-07-30T00:33:25.448Z","avatar_url":"https://github.com/decodelabs.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Veneer\n\n[![PHP from Packagist](https://img.shields.io/packagist/php-v/decodelabs/veneer?style=flat)](https://packagist.org/packages/decodelabs/veneer)\n[![Latest Version](https://img.shields.io/packagist/v/decodelabs/veneer.svg?style=flat)](https://packagist.org/packages/decodelabs/veneer)\n[![Total Downloads](https://img.shields.io/packagist/dt/decodelabs/veneer.svg?style=flat)](https://packagist.org/packages/decodelabs/veneer)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/decodelabs/veneer/integrate.yml?branch=develop)](https://github.com/decodelabs/veneer/actions/workflows/integrate.yml)\n[![PHPStan](https://img.shields.io/badge/PHPStan-enabled-44CC11.svg?longCache=true\u0026style=flat)](https://github.com/phpstan/phpstan)\n[![License](https://img.shields.io/packagist/l/decodelabs/veneer?style=flat)](https://packagist.org/packages/decodelabs/veneer)\n\n### Create automated static frontages for your PHP objects.\n\nUse Veneer to provide easy access to your most commonly used functionality without sacrificing testability.\n\n---\n\n## Install\n\n```bash\ncomposer require decodelabs/veneer\n```\n\n## Usage\nSay you have a common library class you use regularly:\n\n```php\nnamespace Some\\Random\\Library;\n\n// This is a library class you use regularly\nclass MyThing\n{\n    public function doAThing() {\n        echo 'Done!';\n    }\n}\n```\n\n\nYou can bind a static, automatically generated frontage by:\n\n```php\nnamespace App\\Setup;\n\n// This is your environment setup code\nuse DecodeLabs\\Veneer;\nuse Some\\Random\\Library\\MyThing;\nuse App\\CoolThing;\n\nVeneer::register(\n    MyThing::class, // active object class\n    CoolThing::class // frontage class\n);\n\n\n\n\nnamespace Some\\Other\\Code;\n\nuse App\\CoolThing;\n\n// Your general userland code\nCoolThing::doAThing();\n```\n\n\n### Plugins\n\nUnfortunately PHP still doesn't have \u003ccode\u003e\\__getStatic()\u003c/code\u003e yet so we have to statically declare plugin names at binding time, but they're still useful for creating more expansive interfaces.\n\nDefine plugins as properties on your \u003ccode\u003eFacadeTarget\u003c/code\u003e with a \u003ccode\u003ePlugin\u003c/code\u003e attribute. By default, plugins require manual instantiation in the constructor, however you can flag it as \u003ccode\u003eauto\u003c/code\u003e to have it automatically built at bind time, or \u003ccode\u003elazy\u003c/code\u003e if it doesn't need to be loaded straight away.\n\n\n```php\nnamespace My\\Library\n{\n    use DecodeLabs\\Veneer\\Plugin;\n\n    class MyThing {\n\n        #[Plugin]\n        public MyPlugin $plugin;\n\n        #[Plugin(auto: true)]\n        public MyPlugin $autoPlugin;\n\n        #[Plugin(lazy: true)]\n        public MyPlugin $lazyPlugin;\n\n        public function __construct() {\n            $this-\u003eplugin = new MyPlugin();\n        }\n    }\n\n\n    class MyPlugin\n    {\n        public function doAThing(): string {\n            return 'Hello from plugin';\n        }\n    }\n}\n\nnamespace Some\\Other\\Code\n{\n    use My\\Library\\MyThing;\n\n    MyThing::$plugin-\u003edoAThing(); // Hello from plugin\n    MyThing::$autoPlugin-\u003edoAThing(); // Hello from plugin\n    MyThing::$lazyPlugin-\u003edoAThing(); // Hello from plugin\n}\n```\n\nNote, if your target class has a constructor with required parameters, you will need to add \u003ccode\u003edecodelabs/slingshot\u003c/code\u003e to your project to allow Veneer to instantiate it.\n\nLazy instantiation uses the new ghost and proxy functionality in PHP8.4 and will only instantiate the plugin when it is first accessed. Due to the limitations of lazy objects in PHP, you cannot create a lazy proxy for internal classes so you may find that plugins are referenced with a transparent \u003ccode\u003ePlugin\\Wrapper\u003c/code\u003e class which resolves to the actual plugin instance when accessed. This usually isn't an issue unless you try to pass a plugin instance to a function that expects a specific class type, directly from the proxy. In these cases you should return the plugin instance from a method on the target class.\n\n\n### Property Hooks\n\nPHP 8.4 property hooks can be used in combination with Plugins, however be aware that they will conflict with auto and lazy instantiation. Hooks defined with the structure below will effectively act like a lazy loaded plugin, however with the additional benefits of being able to control how it is instantiated rather than relying on Slingshot.\n\n\n```php\nnamespace My\\Library\n{\n    use DecodeLabs\\Veneer\\Plugin;\n\n    class MyThing {\n\n        #[Plugin]\n        protected(set) MyPlugin $plugin {\n            get =\u003e $this-\u003eplugin ??= new MyPlugin();\n        }\n    }\n}\n```\n\nHooks _can_ be virtual (ie, don't require a value backed property), however the proxy will reference the first instantation of a virtual hook and your plugin instances will likely go out of sync.\n\nNote, the \u003ccode\u003eprotected(set)\u003c/code\u003e visibility in the example; it is not a requirement, but it is recommended to prevent direct write access to the property. If you need to replace a plugin instance, you should do so via \u003ccode\u003eVeneer::replacePlugin(\\$providerInstance, \\'propertyName\\', \\$newPlugin)\u003c/code\u003e. This allows Veneer to update the plugin in the static frontage proxy as well as the target instance.\n\n## Licensing\nVeneer is licensed under the MIT License. See [LICENSE](./LICENSE) for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fveneer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecodelabs%2Fveneer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecodelabs%2Fveneer/lists"}