PHPackages                             mattmontgomery/sri-integrity-hashes - 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. mattmontgomery/sri-integrity-hashes

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

mattmontgomery/sri-integrity-hashes
===================================

A tool for generating subresource integrity hashes

v1.5.3(6y ago)01.3k1[2 PRs](https://github.com/mattmontgomery/sri-integrity-hashes/pulls)MITPHP

Since Sep 25Pushed 1y agoCompare

[ Source](https://github.com/mattmontgomery/sri-integrity-hashes)[ Packagist](https://packagist.org/packages/mattmontgomery/sri-integrity-hashes)[ RSS](/packages/mattmontgomery-sri-integrity-hashes/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (10)Dependencies (5)Versions (17)Used By (0)

[![](https://camo.githubusercontent.com/c95a519192e5a61a5bc59378b60e8e2834b03db13bde621507992c5838273ae7/68747470733a2f2f7472617669732d63692e636f6d2f6d6174746d6f6e74676f6d6572792f7372692d696e746567726974792d6861736865732e7376673f6272616e63683d6d6173746572)](https://camo.githubusercontent.com/c95a519192e5a61a5bc59378b60e8e2834b03db13bde621507992c5838273ae7/68747470733a2f2f7472617669732d63692e636f6d2f6d6174746d6f6e74676f6d6572792f7372692d696e746567726974792d6861736865732e7376673f6272616e63683d6d6173746572)[![codecov](https://camo.githubusercontent.com/8b4098c305cccd5f925c45728128fdbcb11e2a526169545f07b46083061faf2f/68747470733a2f2f636f6465636f762e696f2f67682f6d6174746d6f6e74676f6d6572792f7372692d696e746567726974792d6861736865732f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/mattmontgomery/sri-integrity-hashes)

SRI Integrity Hash helper
=========================

[](#sri-integrity-hash-helper)

Loader/Loaders
--------------

[](#loaderloaders)

This is a small class to make interacting with SRI hashes a bit simpler and easier.

Most use cases will want to use the `Loaders` class (see example below).

### Standard Format

[](#standard-format)

Out of the box, assets can be loaded, provided they are in the following format:

```
{
    "scriptName": {
        "src": "script-src.js",
        "integrity": "sha512-test"
    },
    "anotherScriptName": {
        "src": "another-script-src.js",
        "integrity": "sha512-test"
    }
}
```

This can be easily generated from Webpack using the library [webpack-assets-manifest](https://github.com/webdeveric/webpack-assets-manifest).

### Other formats

[](#other-formats)

In the case that other formats are provided or desired, a new Loader implementing `LoaderInterface` may be passed to the `Loaders` class.

### Example

[](#example)

```
use DDM\SRIIntegrityHash\Loaders;

$loaders = new Loaders();

$file = $loaders->getFile('example/assets.json', 'common.js');

echo sprintf("Loaded %s from %s\n", $file->filename, $file->namespace);
echo sprintf("Script tag: %s\n", $file->toScript());
```

#### Using other loaders

[](#using-other-loaders)

By default, the file loader (`DDM\SRIIntegrityHash\FileLoader`) will be used. You can register other autoloaders if you are loading via another source.

Generator
---------

[](#generator)

A script and set of classes exists for generating new asset maps. A command is present in `bin/console.php` which can be used to output JSON, usually to put into its own file. It takes any number of arguments and generates hashes for those files. See below for script usage.

### Script usage

[](#script-usage)

If running from this repository:

```
php bin/sri-assets-generator generate --file=https://apis.google.com/js/api.js --file=https://apis.google.com/js/api-mock.js
```

If running from a composer installation:

```
./vendor/bin/sri-assets-generator ...
```

#### Arguments

[](#arguments)

- `--file` — Pass any number of files with `--file` arguments.
- `--ignore-ssl` — Ignore SSL verification in `FileReader`

### Defining a script in composer.json

[](#defining-a-script-in-composerjson)

If you want a quick and easy way to do the above, you might want to define a scripts entry in your `composer.json`.

```
{
  ...
  "scripts": {
    "generate-assets-map": "sri-assets-generator generate --file=https://apis.google.com/js/api.js"
  }
}
```

### Reading from other sources

[](#reading-from-other-sources)

If you'd like to read from other sources — say, a JSON file with a list of hashes, or an API result, or the database, or something other than just using `file_get_contents`, you can create a new Reader implementing `ReaderInterface`. It can be passed in with as `Generator::read(ReaderInterface, resource)`.

###  Health Score

33

—

LowBetter than 72% of packages

Maintenance29

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity67

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~5 days

Recently: every ~16 days

Total

15

Last Release

2393d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/f424f616c08dda3cbd21197ce2d3740acbbc6720935eed6271cf8ea2101abdb6?d=identicon)[mattmontgomery](/maintainers/mattmontgomery)

---

Top Contributors

[![mattmontgomery](https://avatars.githubusercontent.com/u/3921894?v=4)](https://github.com/mattmontgomery "mattmontgomery (41 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/mattmontgomery-sri-integrity-hashes/health.svg)

```
[![Health](https://phpackages.com/badges/mattmontgomery-sri-integrity-hashes/health.svg)](https://phpackages.com/packages/mattmontgomery-sri-integrity-hashes)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

101466.4k45](/packages/friendsoftypo3-content-blocks)[php-soap/wsdl

Deals with WSDLs

183.8M18](/packages/php-soap-wsdl)[phel-lang/phel-lang

Phel is a functional programming language that compiles to PHP

5155.1k17](/packages/phel-lang-phel-lang)

PHPackages © 2026

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