PHPackages                             jenko/sunscreen - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jenko/sunscreen

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jenko/sunscreen
===============

Protecting your web app from the harmful rays of external dependencies.

45[1 PRs](https://github.com/jenkoian/sunscreen/pulls)PHP

Since May 31Pushed 5y ago1 watchersCompare

[ Source](https://github.com/jenkoian/sunscreen)[ Packagist](https://packagist.org/packages/jenko/sunscreen)[ RSS](/packages/jenko-sunscreen/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (3)Used By (0)

Sunscreen [![Build Status](https://camo.githubusercontent.com/8e276dbc6a34f4361148489828f4b34c3ed3aad5967bd630133b44cfa2017cc3/68747470733a2f2f7472617669732d63692e6f72672f6a656e6b6f69616e2f73756e73637265656e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jenkoian/sunscreen)
===============================================================================================================================================================================================================================================================================================

[](#sunscreen-)

> Protecting you from the harmful rays of third party dependencies.

Re-inventing the wheel is often touted as a bad thing to do in software development. At the same time, relying too heavily on third party dependencies is also touted as a bad thing. What a conundrum?!

The general advice around this seems to be, sure, use third party dependencies but use them responsibly. Wrap them in your own interfaces so that if the dependency becomes out of date, defunct or not fit for purpose, you have your interface, so you can just swap out the dependency or provide your own implementation. [Ports and adapters and all that](http://alistair.cockburn.us/Hexagonal+architecture).

Sunscreen aims to aid this process by automatically creating interfaces and adapters for supported dependencies. Mega!

One thing to be aware of, this aims to simply give you a leg up, get you in the habit of wrapping dependencies in your own interfaces. It does this by copying pretty much verbatim the main interface/class of the third party dependency. This is probably fine for simple dependencies but falls down a little for those with long interfaces or classes with many methods. The advice here would be to define your interface as being whatever *you* need and adapt the other interface to that. In fact that is desired usage for wrapping dependencies in this way. This library won't do that, it will just use the interface/class as is. Therefore, once this library has done it's thing you should definitely review and change/update the interface as per your needs.

[![Sunscreen in action](sunscreen.gif)](sunscreen.gif)

Installation
------------

[](#installation)

```
composer require jenko/sunscreen --dev

```

Then add this to your `composer.json`:

```
    "scripts": {
        "post-package-install": [
            "Jenko\\Sunscreen\\Sunscreen::postPackageInstall"
        ]
    }
```

How it works
------------

[](#how-it-works)

The script will kick in after a package is installed via composer. It will check that package's composer file and look for the following:

```
    "extra": {
        "sunscreen": {
            "interfaces": [
                "Acme\\Package\\MyPackageInterface"
            ]
        }
    }
```

Armed with this information about a package it will use this to generate interfaces/classes and an adapter from the configured interfaces/classes.

If the configuration doesn't exist for the package it will attempt to load configuration from a pool of preconfigured json files.

If it still can't find any configuration it will attempt to guess the main interface by assuming a package has an interface named `PackageNameInterface` or an abstract class `AbstractPackageName` in the main source directory. This is obviously quite unreliable though and the config is favoured.

Sounds great, I author a package, what can I do?
------------------------------------------------

[](#sounds-great-i-author-a-package-what-can-i-do)

As mentioned above, simply add the following bit of config to the `composer.json` file of your package.

```
    "extra": {
        "sunscreen": {
            "interfaces": [
                "Acme\\Package\\MyPackageInterface"
            ]
        }
    }
```

Or if you don't have a main interface but a class, it would be:

```
    "extra": {
        "sunscreen": {
            "classes": [
                "Acme\\Package\\MyPackage"
            ]
        }
    }
```

Ok my favourite package isn't merging my PR, what now?
------------------------------------------------------

[](#ok-my-favourite-package-isnt-merging-my-pr-what-now)

Create a PR to this repository with the preconfigured json for your dependency.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/96de157fc1df70cc339c7d0e2ce3e17eb4fa04798e354a05c86574ed5d11c632?d=identicon)[jenkoian](/maintainers/jenkoian)

---

Top Contributors

[![jenkoian](https://avatars.githubusercontent.com/u/131355?v=4)](https://github.com/jenkoian "jenkoian (15 commits)")

### Embed Badge

![Health badge](/badges/jenko-sunscreen/health.svg)

```
[![Health](https://phpackages.com/badges/jenko-sunscreen/health.svg)](https://phpackages.com/packages/jenko-sunscreen)
```

###  Alternatives

[magirc/magirc

MagIRC - Let the magirc begin!

381.1k](/packages/magirc-magirc)[bjornjohansen/wp-pre-commit-hook

Pre-commit hook for WordPress projects

118.8k3](/packages/bjornjohansen-wp-pre-commit-hook)[nicolaswurtz/chordpro-php

Parse, transpose and format (html,json,plaintext) ChordPro format for songs lyrics with chords.

173.6k](/packages/nicolaswurtz-chordpro-php)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
