PHPackages                             jasny/assetic-extensions - 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. [Caching](/categories/caching)
4. /
5. jasny/assetic-extensions

AbandonedArchivedLibrary[Caching](/categories/caching)

jasny/assetic-extensions
========================

Improved caching for Assetic

v1.0.0(9y ago)01.6kMITPHPPHP &gt;=5.6.0

Since Jun 5Pushed 9y agoCompare

[ Source](https://github.com/jasny/assetic-extensions)[ Packagist](https://packagist.org/packages/jasny/assetic-extensions)[ RSS](/packages/jasny-assetic-extensions/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Jasny Assetic extensions
========================

[](#jasny-assetic-extensions)

[![Build Status](https://camo.githubusercontent.com/8e9aa81eed2db727e4eb24627e3262c47077c759be9db72d48e130bd4017e73f/68747470733a2f2f7472617669732d63692e6f72672f6a61736e792f617373657469632d657874656e73696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/jasny/assetic-extensions)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/9d3588d8fe70b16de8a91b2a5fbae369f2e74062322c4632e3678707ec376b27/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f617373657469632d657874656e73696f6e732f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/assetic-extensions/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0bd03a372b097aafbe4d69f4bf01318b98ab8eb3a5b77b2df6776202930c463c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6a61736e792f617373657469632d657874656e73696f6e732f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/jasny/assetic-extensions/?branch=master)[![SensioLabsInsight](https://camo.githubusercontent.com/5a72bff44645c0aebc0f1751a89eb285869d2e722c2d8404872830f797a1a402/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61316131373435632d313237322d343661332d393536372d3762626235326163646135612f6d696e692e706e67)](https://insight.sensiolabs.com/projects/a1a1745c-1272-46a3-9567-7bbb52acda5a)[![Packagist Stable Version](https://camo.githubusercontent.com/259ba8cf38ace42f526965aff5b9d880084355d1fcbd98a8128ed1905f303db6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a61736e792f617373657469632d657874656e73696f6e732e737667)](https://packagist.org/packages/jasny/assetic-extensions)[![Packagist License](https://camo.githubusercontent.com/7982f1d11ad007077f8ef63e35c61167d087d61ea464a96cb4385d94aaf788cb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a61736e792f617373657469632d657874656e73696f6e732e737667)](https://packagist.org/packages/jasny/assetic-extensions)

Improved caching for [Assetic](https://github.com/kriswallsmith/assetic).

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

[](#installation)

Jasny's Twig Extensions can be easily installed using [composer](http://getcomposer.org/)

```
composer require jasny/assetic-extensions

```

Internal caching when using a factory
-------------------------------------

[](#internal-caching-when-using-a-factory)

The `AssetCacheWorker` wraps each asset in a asset in an `AssetCache` object. This enables the use of asset caching when using a factory.

```
use Assetic\Factory\AssetFactory;
use Jasny\Assetic\AssetCacheWorker;

$factory = new AssetFactory('/path/to/asset/directory/');
$factory->setAssetManager($am);
$factory->setFilterManager($fm);

$factory->addWorker(new AssetCacheWorker(
    new FilesystemCache('/path/to/cache')
));
```

Versioning assets
-----------------

[](#versioning-assets)

The `AssetVersionWorker` add a version number to each generated assets. This works well on a production environment, preventing the need of removing, checking or overwriting the asset files.

If the output file is set to `all.css` and version is set to `1.3.7`, the output file will be named `all-1.3.7.css`.

```
use Assetic\Factory\AssetFactory;
use Jasny\Assetic\AssetVersionWorker;

$factory = new AssetFactory('/path/to/asset/directory/');
$factory->setAssetManager($am);
$factory->setFilterManager($fm);

$factory->addWorker(new AssetVersionWorker($version));
```

Caching when using Twig
-----------------------

[](#caching-when-using-twig)

With the example code from the Assetic readme, each template is parsed on each request. This considerably slows down your application. The `TwigCachingFormulaLoader` using Twig cache to store the assetic formulae is finds in each template. The formula loader uses the [`cache` and `auto_reload` options](https://twig.sensiolabs.org/doc/2.x/api.html#environment-options)of the Twig environment.

The `PersistentAssetWriter` is an asset writer with an `overwrite` option. When overwrite is disabled, existing assets are not overwritten. This can speed up your production environment. It's recommended to add a version number in the output files, either manually or by using the `AssetVersionWorker`.

```
use Jasny\Assetic\PersistentAssetWriter;
use Jasny\Assetic\TwigCachingFormulaLoader;
use Assetic\Extension\Twig\TwigResource;
use Assetic\Factory\LazyAssetManager;

$twigLoader = new Twig_Loader_Filesystem('/path/to/views');
$twig = new Twig_Environment($twigLoader, ['cache' => '/path/to/cache', 'auto_reload' => true]);

$am = new LazyAssetManager($factory);

// enable loading assets from twig templates, caching the formulae
$am->setLoader('twig', new TwigCachingFormulaLoader($twig));

// loop through all your templates
foreach ($templates as $template) {
    $resource = new TwigResource($twigLoader, $template);
    $am->addResource($resource, 'twig');
}

$writer = new PersistentAssetWriter('/path/to/web');
$writer->writeManagerAssets($am);
```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community6

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

3312d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3379a93d51305df325df9045e1a8b205d195e4e8c01312dff53a000ee79002eb?d=identicon)[jasny](/maintainers/jasny)

---

Top Contributors

[![jasny](https://avatars.githubusercontent.com/u/100821?v=4)](https://github.com/jasny "jasny (11 commits)")

### Embed Badge

![Health badge](/badges/jasny-assetic-extensions/health.svg)

```
[![Health](https://phpackages.com/badges/jasny-assetic-extensions/health.svg)](https://phpackages.com/packages/jasny-assetic-extensions)
```

###  Alternatives

[beryllium/cachebundle

Provides an interface to Memcache for Symfony2 applications

32136.0k](/packages/beryllium-cachebundle)

PHPackages © 2026

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