Home>Article>Development Tools> Solution to the slow installation of Yii2 composer
The following column ofcomposer usage tutorialwill introduce to you the solution to the slow installation of Yii2 composer.
It is very convenient to use composer for open source projects that reference PHP in Yii. Open source projects that reference front-end also have the composer plug-in fxp-asset (https://github.com /fxpio/composer-asset-plugin) and Asset Packagist (https://github.com/hiqdev/asset-packagist)
Yii used to use the former by default, but now the new yii2 template uses the latter by default, and the latter The author is very good. He seems to be a heavy Yii user. It seems that he was annoyed by the slow execution of fxp-asset, so he came up with an updated method.
Getting back to the point:
So the faster installation method is Asset Packagist https://asset-packagist.org
In fact, it is 2 steps:
In Turn off the call of fxp-asset in config
Add the configuration of the asset-packagist library to the source list
"config": { "process-timeout": 1800, "fxp-asset": { "enabled": false } }, "repositories": [ { "type": "composer", "url": "https://asset-packagist.org" } ]
If the composer source uses the Alibaba Cloud image, the complete writing is as follows:
"repositories": { "0": { "type": "composer", "url": "https://asset-packagist.org" }, "packagist": { "type": "composer", "url": "https://mirrors.aliyun.com/composer/" } }
It should be noted that when yii defines the vendor path in yii\base\Application, it also defines the bower and npm paths:
/** * Sets the directory that stores vendor files. * @param string $path the directory that stores vendor files. */ public function setVendorPath($path) { $this->_vendorPath = Yii::getAlias($path); Yii::setAlias('@vendor', $this->_vendorPath); Yii::setAlias('@bower', $this->_vendorPath . DIRECTORY_SEPARATOR . 'bower'); Yii::setAlias('@npm', $this->_vendorPath . DIRECTORY_SEPARATOR . 'npm'); }
This is a different solution from the default installation path of asset-packagist. :
Redefine the bower and npm paths in Yii
$config = [ ... 'aliases' => [ '@bower' => '@vendor/bower-asset', '@npm' => '@vendor/npm-asset', ], ... ];
For more composer technical articles, you can visit thecomposer commandUsage tutorial column!
The above is the detailed content of Solution to the slow installation of Yii2 composer. For more information, please follow other related articles on the PHP Chinese website!