Home > Article > Backend Development > yii2 assets modification
In order to force everyone to remove static resource files from the Git repository, I removed all the static resource configuration of nginx.
But it also affects everyone’s debugging of these files on the development machine.
Considering that the module directory under assets is different for different machines, I looked through the yii2 source code and found the following statement.
Found that the algorithm is: $path = (is_file($path) ? dirname($path) : $path) . filemtime($path);
will find filemtime every time to assist encryption. So I thought of removing it first. In this way, the path after encryption is fixed each time. This makes it easier to put files on cdn. And when there are multiple machines, these paths are consistent and there will be no impact.
The file is stored in: vendor/yiisoft/yii2/web/AssetManager.php
The above introduces the modification of yii2 assets, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.