PHPackages                             heyday/silverstripe-hashpath - 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. heyday/silverstripe-hashpath

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

heyday/silverstripe-hashpath
============================

Hash path provides a function in SilverStripe templates which given a path to an asset returns a path including a hash of the asset

3.1.0(2y ago)1475.3k—4.2%11[1 PRs](https://github.com/WPP-Public/akqa-nz-silverstripe-hashpath/pulls)MITPHPCI failing

Since Sep 26Pushed 1y ago27 watchersCompare

[ Source](https://github.com/WPP-Public/akqa-nz-silverstripe-hashpath)[ Packagist](https://packagist.org/packages/heyday/silverstripe-hashpath)[ RSS](/packages/heyday-silverstripe-hashpath/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (2)Versions (22)Used By (0)

Hash Path
=========

[](#hash-path)

Hash Path provides a function in SilverStripe templates which, given a path to an asset, returns a modified path with a file hash appended. In combination with a web server rewrite rule, browser caching can be completely mitigated as the file URL sent to the browser changes whenever the file does.

```
// Template:
$HashPath(css/style.css)

// Rendered:                          ↙ File hash
/themes/my-theme/css/style.vpOQ8F6ybteKQQYND5dzZQ.css
```

License
-------

[](#license)

Hash Path is licensed under an [MIT license](http://heyday.mit-license.org/)

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

[](#installation)

### Composer

[](#composer)

Installing from composer is easy,

Create or edit a `composer.json` file in the root of your SilverStripe project, and make sure the following is present.

```
{
  "require": {
    "heyday/silverstripe-hashpath": "^3.0.0"
  }
}
```

After completing this step, navigate in Terminal or similar to the SilverStripe root directory and run `composer install` or `composer update` depending on whether or not you have composer already in use.

### Web server config

[](#web-server-config)

As Hash Path returns paths that don't exist on disk, a rewrite rule needs to be added to your web server in order to return the file that was originally given to Hash Path. The URL format is `.v[hash]` inserted before the file extension, so you end up with `.v[hash].[extension]`.

#### Apache

[](#apache)

The following is required in your `.htaccess` file or virtual host config.

```

    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.+)\.(v[A-Za-z0-9]+)\.(js|css|png|jpg|gif)$ $1.$3 [L]

```

#### Nginx

[](#nginx)

```
# Hashpath module
location /themes {
	rewrite "^(.+)\.(?:v\w{10,32})\.(js|css|png|jpg|gif)$" $1.$2 last;
	try_files $uri =404;
}

```

How to use
----------

[](#how-to-use)

Provided the correct theme is set, you can simply call `$HashPath` with the asset location relative to the current theme as the first argument.

For example, for a file located at `themes/my-theme/js/general.js` and with `my-theme` current, using:

```

```

will result in:

```

```

If you are wanting to use an asset that is not relative to the current theme, use:

```

```

Unit Testing
------------

[](#unit-testing)

PHP Unit now comes with SS

### Running the unit tests

[](#running-the-unit-tests)

From the command line:

```
vendor/bin/phpunit silverstripe-hashpath/tests

```

Contributing
------------

[](#contributing)

### Code guidelines

[](#code-guidelines)

This project follows the standards defined in:

- [PSR-1](http://www.php-fig.org/psr/psr-1/)
- [PSR-2](http://www.php-fig.org/psr/psr-1/)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity39

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~210 days

Recently: every ~362 days

Total

20

Last Release

981d ago

Major Versions

1.0.4 → 2.0.02013-07-10

1.1.x-dev → 3.0.02017-07-13

2.1.x-dev → 3.0.42022-09-12

### Community

Maintainers

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

---

Top Contributors

[![camspiers](https://avatars.githubusercontent.com/u/51294?v=4)](https://github.com/camspiers "camspiers (23 commits)")[![timhiggs](https://avatars.githubusercontent.com/u/3209433?v=4)](https://github.com/timhiggs "timhiggs (17 commits)")[![stecman](https://avatars.githubusercontent.com/u/2230769?v=4)](https://github.com/stecman "stecman (12 commits)")[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (4 commits)")[![bendubuisson](https://avatars.githubusercontent.com/u/3079189?v=4)](https://github.com/bendubuisson "bendubuisson (3 commits)")[![pieterv](https://avatars.githubusercontent.com/u/438482?v=4)](https://github.com/pieterv "pieterv (2 commits)")[![madmatt](https://avatars.githubusercontent.com/u/893117?v=4)](https://github.com/madmatt "madmatt (1 commits)")[![wernerkrauss](https://avatars.githubusercontent.com/u/1043925?v=4)](https://github.com/wernerkrauss "wernerkrauss (1 commits)")[![jamesLiAKQA](https://avatars.githubusercontent.com/u/87284202?v=4)](https://github.com/jamesLiAKQA "jamesLiAKQA (1 commits)")[![zanderwar](https://avatars.githubusercontent.com/u/13566916?v=4)](https://github.com/zanderwar "zanderwar (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/heyday-silverstripe-hashpath/health.svg)

```
[![Health](https://phpackages.com/badges/heyday-silverstripe-hashpath/health.svg)](https://phpackages.com/packages/heyday-silverstripe-hashpath)
```

###  Alternatives

[silverstripe/multi-domain

Allows multiple domains to access one CMS instance, mapping them to different sections of the hierarchy

141.6k](/packages/silverstripe-multi-domain)

PHPackages © 2026

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