composer慢改源
https://learnku.com/articles/15977/composer-accelerate-and-modify-mirror-source-in-china
$ composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# 取消当前项目配置
composer config --unset repos.packagist
[root@centos1]# php composer.phar
[root@centos1]# /www/server/php/73/bin/php composer.phar install
$sudo /www/server/php/73/bin/php composer.phar config -g repo.packagist composer https://packagist.laravel-china.org
$sudo composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
$sudo /www/server/php/73/bin/php composer global require "laravel/installer"
为什么慢
由于默认情况下执行 composer 各种命令是去国外的 composer 官方镜像源获取需要安装的具体软件信息,所以在不使用代理、不翻墙的情况下,从国内访问国外服务器的速度相对比较慢
如何修改镜像源
可以使用阿里巴巴提供的 Composer 全量镜像 https://mirrors.aliyun.com/composer/
a). 配置只在当前项目生效
composer config repo.packagist composer https://mirrors.aliyun.com/composer/ # 取消当前项目配置 composer config --unset repos.packagist
b). 配置全局生效
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 取消全局配置 composer config -g --unset repos.packagist
c). 使用第三方软件快速修改、切换 composer 镜像源
crm composer registry manager
安装 crm
composer global require slince/composer-registry-manager
列出可用的所有镜像源,前面带 * 代表当前使用的镜像
composer repo:ls -- --------------- ------------------------------------------------ composer https://packagist.org phpcomposer https://packagist.phpcomposer.com aliyun https://mirrors.aliyun.com/composer tencent https://mirrors.cloud.tencent.com/composer huawei https://mirrors.huaweicloud.com/repository/php laravel-china https://packagist.laravel-china.org cnpkg https://php.cnpkg.org sjtug https://packagist.mirrors.sjtug.sjtu.edu.cn -- --------------- ------------------------------------------------
使用 aliyun 镜像源
composer repo:use aliyun # 执行成功之后会输出类似以下信息 [OK] Use the repository [aliyun] success
再次执行 composer repo:ls 命令,看到前面带 * 的就是当前使用的镜像
composer repo:ls # 可以看到 aliyun 前面有一个 * 号,代表当前使用的是 aliyun 的源 --- --------------- ------------------------------------------------
composer https://packagist.org
phpcomposer https://packagist.phpcomposer.com
* aliyun https://mirrors.aliyun.com/composer
tencent https://mirrors.cloud.tencent.com/composer
huawei https://mirrors.huaweicloud.com/repository/php
laravel-china https://packagist.laravel-china.org
cnpkg https://php.cnpkg.org
sjtug https://packagist.mirrors.sjtug.sjtu.edu.cn
--- --------------- ------------------------------------------------
更多用法查看 crm GitHub
本文同步发表在个人网站
https://getcomposer.org/download/
中国镜像
https://pkg.phpcomposer.com/
https://laravel-china.org/composer
$ composer config -g repo.packagist composer https://packagist.laravel-china.org
http://blog.csdn.net/chenlix/article/details/48340741
对于现代语言而言,包管理器基本上是标配。Java有Maven,Python有pip,Ruby有gem,Nodejs有npm。PHP的则是PEAR,不过PEAR坑不少:
- 依赖处理容易出问题
- 配置非常复杂
- 难用的命令行接口
好在我们有Composer,PHP依赖管理的利器。它是开源的,使用起来也很简单,提交自己的包也很容易。
安装Composer
Composer需要PHP 5.3.2+才能运行。
- $ curl -sS https://getcomposer.org/installer | php
这个命令会将composer.phar下载到当前目录。PHAR(PHP 压缩包)是一个压缩格式,可以在命令行下直接运行。
你可以使用--install-dir选项将Composer安装到指定的目录,例如:
- $ curl -sS https://getcomposer.org/installer | php -- --install-dir=bin
当然也可以进行全局安装(Centos6.5一般采用全局安装):
- $ su root
- $ curl -sS https://getcomposer.org/installer | php
- $ mv composer.phar /usr/local/bin/composer
- $ exit OR su chenlix
- $ composer -v
- $ Laravel 如果么样vendor可先执行 composer install -vvv --no-scripts 再 composer update
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
在Mac OS X下也可以使用homebrew安装:
- brew tap josegonzalez/homebrew-php
- brew install josegonzalez/php/composer
不过通常情况下只需将composer.phar的位置加入到PATH环境变量就可以,不一定要全局安装。