composer ¶
Composer管理
安装 ¶
sh
# 安装
brew install composer
# 查看版本
composer -V
常用指令 ¶
基础
sh
# 查看版本
composer -V
composer --version
安装全部、更新全部
sh
# 安装(读取 composer.json )
composer install
# 更新(读取 composer.json )
composer update
安装一个包、更新一个包
sh
# 安装依赖
composer require group/xxx-name --ignore-platform-reqs
# 或者
composer require xxx-name
# 更新依赖
composer update group/xxx-name
# 或者
composer update xxx-name
镜像源 ¶
镜像地址
名称 | 地址 |
---|---|
官方 | https://repo.packagist.org/ |
腾讯 | https://mirrors.cloud.tencent.com/composer/ |
阿里 | https://mirrors.aliyun.com/composer/ |
(卡住)华为 | https://mirrors.huaweicloud.com/repository/php/ |
(不行)华中科技大学 | https://mirrors.hust.edu.cn/composer/ |
(不行)中国全量镜像 | https://packagist.phpcomposer.com |
(不行)中国科技大学 | https://mirrors.ustc.edu.cn/composer/ |
(不行)清华大学 | https://mirrors.tuna.tsinghua.edu.cn/composer/ |
(不行)laravel | https://packagist.laravel-china.org |
替换镜像源
sh
# 局部配置(在当前项目中使用)
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# 全局配置(在全局中使用)推荐
composer config -g repo.packagist composer https://repo.packagist.org/
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/
composer config -g repo.packagist composer https://packagist.composer-proxy.org
composer config -g repo.packagist composer https://p.staticq.com
# 查看镜像库
composer config -gl
# 取消设置
composer config -g --unset repos.packagist