composer 命令总结
总结一些composer 使用命令
https://developer.aliyun.com/composer (引用aliyun composer命令)
Composer全局配置
composer config -l -g
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://mirrors.aliyun.com/composer/
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (I:\306cheWork\bbs.admin.360che.com/vendor)
[bin-dir] {$vendor-dir}/bin (I:\306cheWork\bbs.admin.360che.com/vendor/bin)
[cache-dir] C:/Users/arnold/AppData/Local/Composer
[data-dir] C:/Users/arnold/AppData/Roaming/Composer
[cache-files-dir] {$cache-dir}/files (C:/Users/arnold/AppData/Local/Composer/files)
[cache-repo-dir] {$cache-dir}/repo (C:/Users/arnold/AppData/Local/Composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (C:/Users/arnold/AppData/Local/Composer/vcs)
[cache-ttl] 15552000
[cache-files-ttl] 15552000
[cache-files-maxsize] 300MiB (314572800)
[bin-compat] auto
[discard-changes] false
[autoloader-suffix]
[sort-packages] false
[optimize-autoloader] false
[classmap-authoritative] false
[apcu-autoloader] false
[prepend-autoloader] true
[github-domains] [github.com]
[bitbucket-expose-hostname] true
[disable-tls] false
[secure-http] true
[cafile]
[capath]
[github-expose-hostname] true
[gitlab-domains] [gitlab.com]
[store-auths] prompt
[archive-format] tar
[archive-dir] .
[htaccess-protect] true
[use-github-api] true
[home] C:/Users/arnold/AppData/Roaming/Composer
[github-oauth.github.com] 7f1b975c8f2b2c44264cc6896ad3158bfb6dcad9
镜像配置
在进行install/update的时候,迟迟没有加载出资源,这时候需要看一下镜像,进行更换镜像地址
全局配置
所有项目都会使用该镜像地址
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
取消配置
composer config -g --unset repos.packagist
项目配置
仅修改当前工程配置,仅当前工程可使用该镜像地址
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
取消配置
composer config --unset repos.packagist
安装项目
安装
#如有composer.lock 文件,直接安装. 否则从composer.json 安装最新扩展包和依赖,并生成composer.lock文件
composer install
#从composer.json 安装最新扩展包和依赖, 如果没有指定具体的包配置,composer.json中全部配置进行更新
composer update
#从composer.json修改对应包的配置 或者 命令后跟对应包的配置,并更新到最新
composer update vendor/package
#添加安装 new/package
composer require new/package
#可以指定版本
composer require new/package ~2.5.
调试
composer 命令增加-vvv 可输出详细的信息,命令如下
composer -vvv require new/package
遇到的问题?
建议将composer版本更新到最新版本
composer self-update
执行诊断命令
composer diagnose
清除缓存
composer clear
若项目之前已通过其他源安装,则需要更新 composer.lock 文件,执行命令
composer update --lock