2017 © Pedro Peláez
 

yii2-extension yii2-version-assetmgr

Yii2 asset manager that hashes based on application version instead of mtime. Useful for load balanced sites.

image

jhancock/yii2-version-assetmgr

Yii2 asset manager that hashes based on application version instead of mtime. Useful for load balanced sites.

  • Thursday, August 14, 2014
  • by jhancock
  • Repository
  • 2 Watchers
  • 6 Stars
  • 4,365 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

yii2-version-assetmgr

A drop in replacement AssetManager for the Yii2 framework. Yii's default AssetManager hashes assets based on path + Yii version + file modification time, but if your website is being served behind a load balancer from multiple web servers and the file mtimes are different, this could lead to serving assets from different paths., (*1)

To combat this, instead the VersionAssetManager hashes path + Yii version + application version. Application version is read from the version key of the params array from the configuration file:, (*2)

'params' => [
    'version' => '1.0.0'
],

Installation

The preferred way to install this extension is through composer., (*3)

Either run, (*4)

php composer.phar require --prefer-dist jhancock/yii2-version-assetmgr "*"

or add, (*5)

"jhancock/yii2-version-assetmgr": "*"

to the require section of your composer.json file., (*6)

Configuration

Configure your application to use the VersionAssetManager by adding the following component configuration:, (*7)

'assetManager' => [
    'class' => 'jhancock\VersionAssetMgr\VersionAssetManager',
],

You should then set a version parameter in the params array when you publish your application., (*8)

In the development environment, either omit setting the version key in the config, set it to Development, or omit it altogether and it will default to Development. When the version is Development, we instead hash path + Yii version + time() to guarantee that we always bust cache in the development environment. This means that every pageload will create new folders under your assets directory and copy lots of files. It is therefore recommended that you turn on symlinking by setting linkAssets to true under the assetManager component configuration like so:, (*9)

'assetManager' => [
    'class' => 'jhancock\VersionAssetMgr\VersionAssetManager',
    'linkAssets' => true,
],

The Versions

14/08 2014

dev-master

9999999-dev https://github.com/jasonhancock/yii2-version-assetmgr

Yii2 asset manager that hashes based on application version instead of mtime. Useful for load balanced sites.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Jason Hancock

yii2 assetmanager

14/08 2014

1.0.0

1.0.0.0 https://github.com/jasonhancock/yii2-version-assetmgr

Yii2 asset manager that hashes based on application version instead of mtime. Useful for load balanced sites.

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

by Jason Hancock

yii2 assetmanager