Skip to content

Instantly share code, notes, and snippets.

@Patricy
Last active January 5, 2017 09:24
Show Gist options
  • Select an option

  • Save Patricy/02b43e85238223217b0457d619b1bbfa to your computer and use it in GitHub Desktop.

Select an option

Save Patricy/02b43e85238223217b0457d619b1bbfa to your computer and use it in GitHub Desktop.
Yii2 "assets does not updates" issue
<?php
$config['components']['assetManager']['hashCallback'] = function($path){
$mostRecentFileMTime = 0;
if (is_dir($path)){
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::CHILD_FIRST);
foreach ($iterator as $fileinfo) {
if ($fileinfo->isFile() && $fileinfo->getMTime() > $mostRecentFileMTime) {
$mostRecentFileMTime = $fileinfo->getMTime();
}
}
$path = (is_file($path) ? dirname($path) : $path) . $mostRecentFileMTime;
} else {
$path = (is_file($path) ? dirname($path) : $path) . filemtime($path);
}
return sprintf('%x', crc32($path . Yii::getVersion()));
};
@Patricy
Copy link
Author

Patricy commented Jan 5, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment