PHPackages                             germania-kg/asset-timestamper - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. germania-kg/asset-timestamper

ActiveLibrary[File &amp; Storage](/categories/file-storage)

germania-kg/asset-timestamper
=============================

File modification timestamps for your website assets.

2.0.8(4y ago)0164[1 issues](https://github.com/GermaniaKG/AssetTimestamper/issues)MITPHPPHP ^5.6|^7.0

Since Aug 25Pushed 4y ago2 watchersCompare

[ Source](https://github.com/GermaniaKG/AssetTimestamper)[ Packagist](https://packagist.org/packages/germania-kg/asset-timestamper)[ RSS](/packages/germania-kg-asset-timestamper/feed)WikiDiscussions master Synced 4w ago

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

Germania KG · AssetTimestamper
==============================

[](#germania-kg--assettimestamper)

**File modification timestamps for your website assets.**

[![Packagist](https://camo.githubusercontent.com/28ef9f331e4528c65b98ab547b7785921ee862be42a61e0db8b1786c899fe7b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6765726d616e69612d6b672f61737365742d74696d657374616d7065722e7376673f7374796c653d666c6174)](https://packagist.org/packages/germania-kg/asset-timestamper)[![PHP version](https://camo.githubusercontent.com/3e05b5774d4c0f8b2d4d360b0023c53571837619c289742c59316e355d2cdb4c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6765726d616e69612d6b672f61737365742d74696d657374616d7065722e737667)](https://packagist.org/packages/germania-kg/asset-timestamper)[![Build Status](https://camo.githubusercontent.com/07acbd0646a544a7ce72e436d67ecd75d118ad390c41129d38ecd08c3755d342/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4765726d616e69614b472f417373657454696d657374616d7065722e7376673f6c6162656c3d5472617669732532304349)](https://travis-ci.org/GermaniaKG/AssetTimestamper)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/a00ddc092484434ce78c46503d0e2845c70f6e15556143e163028523c4fe5c8e/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4765726d616e69614b472f417373657454696d657374616d7065722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GermaniaKG/AssetTimestamper/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/a8bf99b1d38a40eb3e257d46230690de5c75d9812559c622ee7de58dfc853a5d/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4765726d616e69614b472f417373657454696d657374616d7065722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GermaniaKG/AssetTimestamper/?branch=master)[![Build Status](https://camo.githubusercontent.com/a77969c2c7efd912b5c3706c769680ed7f02e329cc628976f0682525f053637f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4765726d616e69614b472f417373657454696d657374616d7065722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/GermaniaKG/AssetTimestamper/build-status/master)

This Callable looks for a given asset file (e.g. CSS, JS usually) in a base directory, extracts its [modification time](http://php.net/manual/en/function.filemtime.php)and returns a modified asset path that contains that very timestamp.

**For remote files,** no timestamps will be added. AssetTimestamper will check for *host* entry in PHP's *parse\_url's* result array.

See Chris Coyier's article [“Strategies for Cache-Busting CSS”](https://css-tricks.com/strategies-for-cache-busting-css), chapter [“Changing File Name“](https://css-tricks.com/strategies-for-cache-busting-css/#article-header-id-2). Please note — As Chris Coyier [points out](https://css-tricks.com/strategies-for-cache-busting-css/#article-header-id-3), this technique may slow down server response. Using this technique for *only some files* should be fine, be aware to not over-use it.

Installation with Composer
--------------------------

[](#installation-with-composer)

```
$ composer require germania-kg/asset-timestamper
```

Alternatively, add this package directly to your *composer.json:*

```
"require": {
    "germania-kg/asset-timestamper": "^2.0"
}
```

Upgrade from v1
---------------

[](#upgrade-from-v1)

In v1, a **FileException** was thrown if a given asset did not exist. As of version 2, the original asset file name will be returned. If you have not seen this *FileException* until now, you will have to do nothing. All others have to remove *FileException* catch blocks.

**Deprecation warning:** The *FileException* class is still available with this package and will be removed in Release Version 3. Discuss at [issue #1](https://github.com/GermaniaKG/AssetTimestamper/issues/1).

Usage
-----

[](#usage)

You do not need to have a leading directory separator slash, as it will internally be “glued in” if neccessary. However, the result will have (or miss) the slash, depending on how you pass in the asset file name.

```
