Composer 的linux安装更新国内镜像

编程语言
0 35

csroad
csroad 举报
05月19日 11:29

接下来我们可以更改 Packagist 为国内镜像:

composer config -g repo.packagist composer https://packagist.phpcomposer.com

Linux 平台

Linux 平台可以使用以下命令来安装:

# php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
# php composer-setup.php

All settings correct for using Composer
Downloading...

Composer (version 1.6.5) successfully installed to: /root/composer.phar
Use it: php composer.phar

移动 composer.phar,这样 composer 就可以进行全局调用:

# mv composer.phar /usr/local/bin/composer

切换为国内镜像:

# composer config -g repo.packagist composer https://packagist.phpcomposer.com

更新 composer:

# composer selfupdate

=====

打开命令行窗口(windows用户)或控制台(Linux、Mac 用户),进入你的项目的根目录(也就是 composer.json 文件所在目录),执行如下命令:

composer config repo.packagist composer https://packagist.phpcomposer.com

上述命令将会在当前项目中的 composer.json 文件的末尾自动添加镜像的配置信息(你也可以自己手工添加):

    "repositories": {

        "packagist": {

            "type": "composer",

            "url": "https://packagist.phpcomposer.com"

        }

    }

————————————————