一、列表内容
composer
composer list
二、查看当前镜像源
composer config -l -g
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://packagist.org
或者
composer config -g repo
{“packagist.org”:{“type”:”composer”,”url”:”https:\/\/packagist.org”}}
三、配置镜像源
全局配置国内镜像
composer config -g repo.packagist composer
https://packagist.phpcomposer.com
全局恢复默认镜像
composer config -g repo.packagist composer https://packagist.org
单项目配置镜像
编辑composer.json文件,配置
“repositories”: {
“packagist”: {
“type”:”composer”,
“url”: “https://packagist.phpcomposer.com” //”url”: “https://packagist.org”
} }
单项目命令行配置
composer config repo.packagist composer https://packagist.phpcomposer.com
四、安装依赖
composer install xxxxx/xxxx
更新单个依赖
composer update xxxxx/xxxx
或者
composer require xxx:version
根据包的名称,列出包的相关信息
composer show -all xxxx
搜索相关包的信息
composer search monolog
五、创建 composer.json 文件
composer init
例如下面生成的composer.json文件
{
“name”: “xxxxxx”,
“require-dev”: {
“maatwebsite/excel”: “1.0” },
“authors”: [ {
“name”:”xxx”,
“email”: “xxxx@xxx.com” } ],
“require”: {}
}
检查
composer diagnose
更新composer
composer self-update
清空缓存
composer clear-cache
配置相关项
composer config …
配置所有的配置项,例如:
composer config secure-http true(false)
优化自动加载
composer dump-autoload -optimize
---------------------
作者:r_martian
来源:CSDN
原文:https://blog.csdn.net/cjqh_hao/article/details/76039497
版权声明:本文为博主原创文章,转载请附上博文链接!