PHPackages                             stephanecoinon/autoversion - 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. stephanecoinon/autoversion

AbandonedLibrary[Caching](/categories/caching)

stephanecoinon/autoversion
==========================

Suffix asset file name with a timestamp to invalidate cache if a new asset is uploaded on the server.

0.1.0(11y ago)1419PHPPHP &gt;=5.4.0

Since Jul 16Pushed 8y ago1 watchersCompare

[ Source](https://github.com/stephanecoinon/autoversion)[ Packagist](https://packagist.org/packages/stephanecoinon/autoversion)[ RSS](/packages/stephanecoinon-autoversion/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (1)Versions (1)Used By (0)

AutoVersion [![Build Status](https://camo.githubusercontent.com/966f98c971f4dfed1b61e493ba8103bd09691cb5ce4ff58ff6bb3891e8735a30/68747470733a2f2f7472617669732d63692e6f72672f7374657068616e65636f696e6f6e2f6175746f76657273696f6e2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/stephanecoinon/autoversion)
=========================================================================================================================================================================================================================================================================================================================

[](#autoversion-)

Suffix asset file names with a timestamp to invalidate cache if a new asset is uploaded on the server.

When you include assets like images, stylesheets or javascripts, your website visitors might not see new changes depending on their browser cache settings. AutoVersion will force the cache to invalidate.

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

[](#installation)

In your terminal, just run:

```
composer require "stephanecoinon/autoversion":"dev-master"
```

Configuration
-------------

[](#configuration)

This package is framework agnostic, the configuration process is:

```
// Auto-load composer packages
require 'vendor/autoload.php';

// Configure the document root
AutoVersion::setDocumentRoot('/var/www/html/public');
```

And if you're using the excellent [Laravel](http://laravel.com) framework, it's even simpler: just add the service provider in `app/config/app.php`:

```
'providers' => array(

	// Your current providers are here ...

	'Coinon\AutoVersion\AutoVersionServiceProvider',
),
```

The service provider will take care of:

- automatically loading the package
- configuring the document root to `public_path()`
- adding the `AutoVersion` class as an alias making it accessible easily from anywhere

Usage
-----

[](#usage)

In your views, just call:

```
// $pathToAsset is relative to the document root configured above
AutoVersion::asset($pathToAsset);
```

for example:

```
