{"id":25893454,"url":"https://github.com/jenkoian/sunscreen","last_synced_at":"2025-07-22T13:03:16.226Z","repository":{"id":55955112,"uuid":"60021671","full_name":"jenkoian/sunscreen","owner":"jenkoian","description":"☀️ Protecting you from the harmful rays of third party dependencies.","archived":false,"fork":false,"pushed_at":"2020-12-04T15:55:30.000Z","size":381,"stargazers_count":4,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-08T09:06:23.563Z","etag":null,"topics":[],"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/jenkoian.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":"2016-05-30T15:48:36.000Z","updated_at":"2019-08-07T22:42:40.000Z","dependencies_parsed_at":"2022-08-15T10:11:05.605Z","dependency_job_id":null,"html_url":"https://github.com/jenkoian/sunscreen","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkoian%2Fsunscreen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkoian%2Fsunscreen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkoian%2Fsunscreen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jenkoian%2Fsunscreen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jenkoian","download_url":"https://codeload.github.com/jenkoian/sunscreen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241576890,"owners_count":19984939,"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":[],"created_at":"2025-03-02T21:36:11.563Z","updated_at":"2025-03-02T21:36:12.959Z","avatar_url":"https://github.com/jenkoian.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Sunscreen [![Build Status](https://travis-ci.org/jenkoian/sunscreen.svg?branch=master)](https://travis-ci.org/jenkoian/sunscreen)\n\n\u003e Protecting you from the harmful rays of third party dependencies.\n\nRe-inventing the wheel is often touted as a bad thing to do in software development. At the same time, relying too heavily\non third party dependencies is also touted as a bad thing. What a conundrum?!\n\nThe general advice around this seems to be, sure, use third party dependencies but use them responsibly. Wrap them in your\nown interfaces so that if the dependency becomes out of date, defunct or not fit for purpose, you have your interface, so\nyou can just swap out the dependency or provide your own implementation. [Ports and adapters and all that](http://alistair.cockburn.us/Hexagonal+architecture).\n\nSunscreen aims to aid this process by automatically creating interfaces and adapters for supported dependencies. Mega!\n\nOne thing to be aware of, this aims to simply give you a leg up, get you in the habit of wrapping dependencies in your\nown interfaces. It does this by copying pretty much verbatim the main interface/class of the third party dependency. This \nis probably fine for simple dependencies but falls down a little for those with long interfaces or classes with many methods.\nThe advice here would be to define your interface as being whatever *you* need and adapt the other interface to that.  In\nfact that is desired usage for wrapping dependencies in this way. This library won't do that, it will just use the interface/class \nas is. Therefore, once this library has done it's thing you should definitely review and change/update the interface as per your needs.\n\n![Sunscreen in action](sunscreen.gif)\n\n## Installation\n\n```\ncomposer require jenko/sunscreen --dev\n```\n\nThen add this to your `composer.json`:\n\n```json\n    \"scripts\": {\n        \"post-package-install\": [\n            \"Jenko\\\\Sunscreen\\\\Sunscreen::postPackageInstall\"\n        ]\n    }\n```\n\n## How it works\n\nThe script will kick in after a package is installed via composer. It will check that package's composer file and look for \nthe following:\n\n```json\n    \"extra\": {\n        \"sunscreen\": {\n            \"interfaces\": [\n                \"Acme\\\\Package\\\\MyPackageInterface\"\n            ]\n        }\n    }\n```\n\nArmed with this information about a package it will use this to generate interfaces/classes and an adapter from the configured\ninterfaces/classes.\n\nIf the configuration doesn't exist for the package it will attempt to load configuration from a pool of preconfigured json files.\n\nIf it still can't find any configuration it will attempt to guess the main interface by assuming a package has an interface named\n`PackageNameInterface` or an abstract class `AbstractPackageName` in the main source directory. \nThis is obviously quite unreliable though and the config is favoured.\n\n## Sounds great, I author a package, what can I do?\n\nAs mentioned above, simply add the following bit of config to the `composer.json` file of your package.\n\n```json\n    \"extra\": {\n        \"sunscreen\": {\n            \"interfaces\": [\n                \"Acme\\\\Package\\\\MyPackageInterface\"\n            ]\n        }\n    }\n```\n\nOr if you don't have a main interface but a class, it would be:\n\n```json\n    \"extra\": {\n        \"sunscreen\": {\n            \"classes\": [\n                \"Acme\\\\Package\\\\MyPackage\"\n            ]\n        }\n    }\n```\n\n## Ok my favourite package isn't merging my PR, what now?\n\nCreate a PR to this repository with the preconfigured json for your dependency.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkoian%2Fsunscreen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjenkoian%2Fsunscreen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjenkoian%2Fsunscreen/lists"}