解决Composer包在某些情况下拉不来了的问题
# 问题说明
总所周知 国内由于某些神秘力量 在我们访问外网的时候比较慢或者访问不到,包括composer包拉不下来
# 解决方案
更换阿里云composer镜像 (这个大家都知道)
更换composer包的Github网址 下面是示例(以极光推送包为示例代码)
# 示例代码
打开 package.json 文件 找到其中的 repositories
// .....
"repositories": {
"packagist": {
"type": "vcs",
"url": "https://github.com/jpush/jpush-api-php-client" // 你需要拉下来包的GitHub网址
}
}
2
3
4
5
6
7
并且在 package.json 文件的 require 字段中加入
"jpush/jpush": "*"
之后在命令行运行
composer update
# 提示
在执行过程中会提示需要一个token 并且附带一个Github网址打开领取你的token复制到命令行回车就OK了
# 需要设置的代理
HTTP 形式: git clone https://github.com/xxx/git.git
SSH 形式: git clone git@github.com:xxx/git.git
# HTTP 代理
git config --global http.proxy http://127.0.0.1:8080 git config --global https.proxy http://127.0.0.1:8080
# socks5 代理(如 Shadowsocks)
git config --global http.proxy socks5://127.0.0.1:1080 git config --global https.proxy socks5://127.0.0.1:1080
# 取消设置
git config --global --unset http.proxy git config --global --unset https.proxy
# 只对 github 进行代理, 对国内的仓库不影响, 可以这样设置
git config --global http.https://github.com.proxy https://127.0.0.1:1080 git config --global https.https://github.com.proxy https://127.0.0.1:1080