Home > Development Tools > composer > Solution to the slow installation of Yii2 composer

Solution to the slow installation of Yii2 composer

藏色散人
Release: 2019-10-25 13:52:13
forward
4191 people have browsed it

The following column of composer usage tutorial will introduce to you the solution to the slow installation of Yii2 composer.

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"
    }
]
Copy after login

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/"
        }
    }
Copy after login

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');
    }
Copy after login

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',
        ],
        ...
    ];
Copy after login

For more composer technical articles, you can visit the composer 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!

Related labels:
source:segmentfault.com
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