yii2 assets modification

WBOY
Release: 2016-07-29 09:05:58
Original
1642 people have browsed it

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.


/**
     * Generate a CRC32 hash for the directory path. Collisions are higher
     * than MD5 but generates a much smaller hash string.
     * @param string $path string to be hashed.
     * @return string hashed string.
     */
protected function hash($path)
{
if (is_callable($this->hashCallback)) {
return call_user_func($this->hashCallback, $path );
                                                                                                  $path = ( )));


}

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template