1.安装composer
官方源:
composer config -g repo.packagist composer https://packagist.phpcomposer.com
阿里云源:
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
腾讯云源:
composer config -g repos.packagist composer https://mirrors.cloud.tencent.com/composer/
2.常用命令
查看composer版本
composer -v
升级composer版本
composer self-update
composer从2版本降到1版本
composer self-update 1.10.24
或者
composer self-update --1
更新但不自动升级到更高版本
composer update --no-plugins
查看composer 的配置
composer config -g -l
修改composer 的镜像源
composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/
composer 比较常用的镜像源
composer官方 https://packagist.org
php官方 https://packagist.phpcomposer.com
阿里云 https://mirrors.aliyun.com/composer
腾讯云 https://mirrors.cloud.tencent.com/composer
华为云 https://mirrors.huaweicloud.com/repository/php
laravel(中国) https://packagist.laravel-china.org
显示所有的扩展包
composer show -i
查看关联包
composer why 命名空间/包名
例如: composer why symfony/deprecation-contracts
移除包
composer remove 命名空间/包名
例如: composer remove symfony/deprecation-contracts
安装某个扩展包
composer require 命名空间/包名
例如: composer require symfony/deprecation-contracts
3.常见问题
1、更新composer出现版本不匹配,插件丢失等问题的解决方法:
删除composer.lock 文件,删除vendor目录里的全部文件
重新执行
composer install --ignore-platform-reqs
或者
composer update --ignore-platform-reqs
--ignore-platform-reqs 这个是忽略php版本匹配的意思
转自:https://blog.csdn.net/qq15577969/article/details/126687778
微信公众号那个不行了嘛