whcoding whcoding
首页
归档
关于
GitHub (opens new window)
首页
归档
关于
GitHub (opens new window)
  • PHP

  • Composer

    • 解决Composer包在某些情况下拉不来了的问题
    • 环境

    • 其他

    • 技术
    • Composer
    whcoding
    2019-11-21
    目录

    解决Composer包在某些情况下拉不来了的问题

    # 问题说明

    总所周知 国内由于某些神秘力量 在我们访问外网的时候比较慢或者访问不到,包括composer包拉不下来

    # 解决方案

    1. 更换阿里云composer镜像 (这个大家都知道)

    2. 更换composer包的Github网址 下面是示例(以极光推送包为示例代码)

    # 示例代码

    打开 package.json 文件 找到其中的 repositories

    	// .....
    	"repositories": {
    	    "packagist": {
    	        "type": "vcs",
    	        "url": "https://github.com/jpush/jpush-api-php-client"  // 你需要拉下来包的GitHub网址
    	    }
    	}
    
    1
    2
    3
    4
    5
    6
    7

    并且在 package.json 文件的 require 字段中加入

    "jpush/jpush": "*"
    
    1

    之后在命令行运行

    composer update
    
    1

    # 提示

    在执行过程中会提示需要一个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

    #composer
    上次更新: 2022/08/30, 23:31:20
    PHP 自动加载原理分析
    Ubuntu 系统apt安装 lnmp环境

    ← PHP 自动加载原理分析 Ubuntu 系统apt安装 lnmp环境→

    Theme by Vdoing | Copyright © 2018-2023
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式