Download the PHP package jhancock/yii2-version-assetmgr without Composer
On this page you can find all versions of the php package jhancock/yii2-version-assetmgr. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jhancock/yii2-version-assetmgr
More information about jhancock/yii2-version-assetmgr
Files in jhancock/yii2-version-assetmgr
Package yii2-version-assetmgr
Short Description Yii2 asset manager that hashes based on application version instead of mtime. Useful for load balanced sites.
License BSD-3-Clause
Homepage https://github.com/jasonhancock/yii2-version-assetmgr
Informations about the package yii2-version-assetmgr
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.
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:
Installation
The preferred way to install this extension is through composer.
Either run
or add
to the require section of your composer.json
file.
Configuration
Configure your application to use the VersionAssetManager by adding the following component configuration:
You should then set a version
parameter in the params
array when you publish
your application.
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: