composer切換國內映象
阿新 • • 發佈:2019-02-09
切換國內映象源
國內映象
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