PHPackages                             m1/twig-asset-rev-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. m1/twig-asset-rev-extension

ActiveLibrary[Templating &amp; Views](/categories/templating)

m1/twig-asset-rev-extension
===========================

Twig Asset Rev Extension adds a asset\_rev twig filter so you can use asset revisioning from files, perfect for use with gulp-rev or grunt-rev

1.1.1(9y ago)348.9k↓45.5%1MITPHPPHP &gt;=5.3.0

Since Jan 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/m1/TwigAssetRevExtension)[ Packagist](https://packagist.org/packages/m1/twig-asset-rev-extension)[ Docs](https://github.com/M1/:package_name)[ RSS](/packages/m1-twig-asset-rev-extension/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

TwigAssetRevExtension
=====================

[](#twigassetrevextension)

[![Author](https://camo.githubusercontent.com/ed167a3f87bb811a7e157913a2461cc647ef51ca73a97b674a7805f54b8caa70/687474703a2f2f696d672e736869656c64732e696f2f62616467652f617574686f722d406d696c657363726f78666f72642d626c75652e7376673f7374796c653d666c61742d737175617265)](https://twitter.com/milescroxford)[![Latest Version on Packagist](https://camo.githubusercontent.com/b7490ee5388e6ea8cbf4918ef93a2bc8a9e6d3cdb9b0421c222e93f311cc0db9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d312f747769672d61737365742d7265762d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1/twig-asset-rev-extension)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/1b67042b2f9a56074427700525274ce2bc95356176147f19139d4c8d8014a23c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6d312f547769674173736574526576457874656e73696f6e2f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/m1/TwigAssetRevExtension)[![Coverage Status](https://camo.githubusercontent.com/433329041475a789eeb7862a8e59a07a1cfb2bb0df96186ff14a6ed72c1bbb20/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d312f547769674173736574526576457874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/m1/TwigAssetRevExtension/code-structure)[![Quality Score](https://camo.githubusercontent.com/181cbf0474bdbc2b9c6c2dee5175d7d8e820ac5efde8eaf201009ca7b949bffd/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6d312f547769674173736574526576457874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/m1/TwigAssetRevExtension)[![Total Downloads](https://camo.githubusercontent.com/3a24e8f81c8d0a3aed75d97d76f65fe05ec20ec9b508544fb7683841c5b70420/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d312f747769672d61737365742d7265762d657874656e73696f6e2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/m1/twig-asset-rev-extension)

Twig Asset Rev Extension adds a `asset_rev` twig filter so you can use asset revisioning from files, perfect for use and tested with [`gulp-rev`](https://github.com/sindresorhus/gulp-rev)/[`gulp-rev-all`](https://github.com/smysnk/gulp-rev-all)or [`grunt-rev`](https://github.com/cbas/grunt-rev)

Requirements
------------

[](#requirements)

`TwigAssetRevExtension` requires PHP version `5.3+`.

Install
-------

[](#install)

Via Composer

```
$ composer require m1/twig-asset-rev-extension
```

Usage
-----

[](#usage)

`TwigAssetRevExtension` works like other twig extensions, just add the extension using `$twig->addExtension()`.

```
Use \M1\TwigAssetRevExtension\TwigAssetRevExtension;

$assets = json_decode(file_get_contents('rev-manifest.json'), true);
$asset_rev = new TwigAssetRevExtension($assets);
$twig->addExtension($asset_rev);
```

`example.twig`:

```

```

`rev-manifest.json`:

```
{
  "css/app.css": "css/app.bd6efcb01bc3.css",
  "css/app.min.css": "css/app.min.9f8d3d255c1f.css",
}
```

Symfony usage
-------------

[](#symfony-usage)

You can register the extension automatically in Symfony via `app/config/services.yml`.

```
twig.extension.asset_rev:
  class: M1\TwigAssetRevExtension\TwigAssetRevExtension
  arguments: [ "%kernel.root_dir%/../web/js/manifest.json", false ]
  tags:
    - { name: twig.extension }
```

Setup
-----

[](#setup)

```
new TwigAssetRevExtension(mixed $assets [, bool $minified = true ] )
```

#### Parameters

[](#parameters)

##### assets

[](#assets)

The path to the JSON file, or the array of assets and rev'd assets, an example:

```
array(
  "css/app.css" => "css/app.bd6efcb01bc3.css",
  "css/app.min.css" => "css/app.min.9f8d3d255c1f.css",
  "js/app.admin.js" => "js/app.admin.96b3cc15df52.js",
  "js/app.admin.min.js" => "js/app.admin.min.dbdc6d8e2114.js",
  "js/app.admin.plugins.js" => "js/app.admin.plugins.927a9b50dd18.js",
  "js/app.admin.plugins.min.js" => "js/app.admin.plugins.min.283a1a903f4a.js",
  "img/image-jpg.jpg" => "img/image-jpg.219a48cfe072.jpg",
  "img/image-png.png" => "img/image-png.1691620d298a.png",
  "img/image-gif.gif" => "img/image-gif.bcd9f17c5cf8.png"
)
```

If using `gulp-rev` or `gulp-rev-all` this is just the contents of `rev-manifest.json` - parsing the json file with `json_decode(file_get_contents('rev-manifest.json'), true);`. You should probably cache this result though so you don't have to read the file every request.

##### minified

[](#minified)

When `true` this means that `TwigAssetRevExtension` will pass back minified assets if they're available. Twig debug mode or Silex debug mode override this and it won't pass back minified assets in development.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Miles Croxford](https://github.com/m1)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 93.3% 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 ~117 days

Total

4

Last Release

3417d ago

Major Versions

0.1.0 → 1.0.02016-08-02

### Community

Maintainers

![](https://www.gravatar.com/avatar/60c0a2476209607aae2ba8d4c99b094baa1e482740622cd19c9ef6bb86b0ba47?d=identicon)[m1](/maintainers/m1)

---

Top Contributors

[![m1](https://avatars.githubusercontent.com/u/978089?v=4)](https://github.com/m1 "m1 (14 commits)")[![alexsegura](https://avatars.githubusercontent.com/u/1162230?v=4)](https://github.com/alexsegura "alexsegura (1 commits)")

---

Tags

symfonytwigjavascriptcssJSfilterextensionassetsilexm1twig-asset-rev-extensionTwigAssetRevExtensionrevgulp-revgrunt-revasset\_rev

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[nochso/html-compress-twig

Twig extension for compressing HTML and inline CSS/Javascript

84468.6k8](/packages/nochso-html-compress-twig)[tales-from-a-dev/twig-tailwind-extra

A Twig extension for Tailwind

34802.1k9](/packages/tales-from-a-dev-twig-tailwind-extra)

PHPackages © 2026

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