PHPackages                             ivoba/twig-asset-version-extension - 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. [Templating &amp; Views](/categories/templating)
4. /
5. ivoba/twig-asset-version-extension

ActiveTwig-extension[Templating &amp; Views](/categories/templating)

ivoba/twig-asset-version-extension
==================================

v1.0.0(11y ago)118.3kMITPHPPHP &gt;=5.4

Since Dec 17Pushed 11y ago1 watchersCompare

[ Source](https://github.com/ivoba/twig-asset-version-extension)[ Packagist](https://packagist.org/packages/ivoba/twig-asset-version-extension)[ RSS](/packages/ivoba-twig-asset-version-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

Asset Version Twig Extension
============================

[](#asset-version-twig-extension)

Render versioned asset filenames in twig.

[![Build Status](https://camo.githubusercontent.com/98fca5dc88459f453565af5cb8340dfa03c343fb684f2319b0e4067f78a86311/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f69766f62612f747769672d61737365742d76657273696f6e2d657874656e73696f6e2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/ivoba/twig-asset-version-extension)

Install
-------

[](#install)

Use composer:

```
require ivoba/twig-asset-version-extension

```

Usage
-----

[](#usage)

In your twig files:

```

```

This will render : /dist/js/script.12345.js

Where *12345* is by default the md5 content digest of the file.

The **trick** is to leave the file with the original filename: */dist/js/script.js*
and let the webserver rewrite the url by pattern.

F.e, for the above pattern and apache mod\_rewrite you could use:

```
RewriteRule ^dist/(.+)\.(.+)\.(js|css|png|jpg|gif)$ /dist/$1.$3 [L]

```

For nginx:

```
location ~* ^.+\.(dist)$ {
        rewrite ^(.+)\.(\d+)\.(dist)$ $1.$3 last;
        expires 31536000s;

```

Integration
-----------

[](#integration)

### Silex:

[](#silex)

Register the Twig Extension:

```
$app['twig'] = $app->share($app->extend('twig', function ($twig, $app) {
    $twig->addExtension(new \Ivoba\AssetVersion\Twig\AssetVersionExtension(new \Ivoba\AssetVersion\Version\Md5ContentAssetVersion(),
                                                                           new \Ivoba\AssetVersion\Namer\DefaultNamer(),
                                                                            __DIR__. '/../web'));
    return $twig;
}));

```

### Symfony:

[](#symfony)

Add this in your services.xml:

```

    %asset_dir%

```

Extend
------

[](#extend)

You can create your own Version or Namer class by implementing their resp. interfaces and pass them to the extension.
F.e if you prefer timestamp as version or a different pattern in the filename.

In the Extension you can add options as 4th parameter, as for now it only offers options\['asset.directory'\], as standard directory for assets.

Credits
-------

[](#credits)

Read more about the idea:

[http://www.bephpug.de/folien/asset\_fingerprinting\_with\_php\_demo\_2012-08-07.pdf](http://www.bephpug.de/folien/asset_fingerprinting_with_php_demo_2012-08-07.pdf)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4164d ago

### Community

Maintainers

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

---

Top Contributors

[![ivoba](https://avatars.githubusercontent.com/u/471254?v=4)](https://github.com/ivoba "ivoba (8 commits)")

---

Tags

twigtwig-extensiontwigassetscachebuster

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ivoba-twig-asset-version-extension/health.svg)

```
[![Health](https://phpackages.com/badges/ivoba-twig-asset-version-extension/health.svg)](https://phpackages.com/packages/ivoba-twig-asset-version-extension)
```

###  Alternatives

[dms/twig-extension-bundle

DMS Twig Extension Bundle, leverages Fabien Potencier's extra twig extensions for your website.

19296.3k](/packages/dms-twig-extension-bundle)[odan/twig-assets

Caching and compression for Twig assets (JavaScript and CSS).

2223.0k4](/packages/odan-twig-assets)[frozzare/digster

Twig templates for WordPress

107.1k](/packages/frozzare-digster)

PHPackages © 2026

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