composer切换国内镜像

切换国内镜像源

国内镜像

https://packagist.phpcomposer.com
https://packagist.laravel-china.org

全局配置

composer config -g repo.packagist composer https://packagist.phpcomposer.com

查看配置

$ composer config -l
[repositories.packagist.org.type] composer
[repositories.packagist.org.url] https://packagist.phpcomposer.com
[process-timeout] 300
[use-include-path] false
[preferred-install] auto
[notify-on-install] true
[github-protocols] [https, ssh]
[vendor-dir] vendor (F:\java\Servlet\demo1\1/vendor)
[bin-dir] {$vendor-dir}/bin (F:\java\Servlet\demo1\1/vendor/bin)
[cache-dir] C:/Users/TOYOTA/AppData/Local/Composer
[data-dir] C:/Users/TOYOTA/AppData/Roaming/Composer
[cache-files-dir] {$cache-dir}/files (C:/Users/TOYOTA/AppData/Local/Composer/files)
[cache-repo-dir] {$cache-dir}/repo (C:/Users/TOYOTA/AppData/Local/Composer/repo)
[cache-vcs-dir] {$cache-dir}/vcs (C:/Users/TOYOTA/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] 1
[home] C:/Users/TOYOTA/AppData/Roaming/Composer

repositories.packagist.org.url已经发生改变,证明配置成功,–global (-g)【全局】实际操作的是$COMPOSER_HOME/config.json

单项目

进入项目目录 运行以下命令

composer config repo.packagist composer https://packagist.phpcomposer.com

上述命令将会在当前项目中的 composer.json 文件的末尾自动添加镜像的配置信息(你也可以自己手工添加):

"repositories": {
    "packagist": {
        "type": "composer",
        "url": "https://packagist.phpcomposer.com"
    }
}

使用第三方软件快速修改、切换 composer 镜像源

安装 crm

composer global require slince/composer-registry-manager

列出当前可用的所有镜像源

$ composer repo:ls
   composer       https://packagist.org
 * phpcomposer    https://packagist.phpcomposer.com
   composer-proxy https://packagist.composer-proxy.org
   laravel-china  https://packagist.laravel-china.org

标“*”表示当前正在使用的源;

使用 phpcomposer 镜像源

composer repo:use laravel-china

更多用法查看 crm GitHub

你可能感兴趣的:(php)