Composer安装: Connection Error [ERR_CONNECTION]: Unable to connect to getcomposer.org Request to...

来源:互联网 发布:淘宝怎么修改发货单号 编辑:程序博客网 时间:2024/05/21 15:41

Windows中Composer安装:

https://getcomposer.org/Composer-Setup.exe,下载安装包,运行安装,选择相应的php.ini(此处composer会将此php的路径加入到环境变量)

注:若安装过程中:

Connection Error [ERR_CONNECTION]: Unable to connect to getcomposer.orgRequest to https://getcomposer.org/installer failed with errors:SSL: Handshake timed out. Failed to enable crypto. Failed to open stream: operation failed

出现以上错误导致安装不成功的解决办法:

  1. 下载ca-bundle.crt 文件 (https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt)
  2. 将ca-bundle.crt 放到任意文件夹中(例如 c:/phpstudy/ca-bundle.crt)
  3. 找到安装Composer的 php.ini,打开文件,添加以下两行数据
    curl.cainfo=c:/phpStudy/ca-bundle.crt
    openssl.cafile=c:/phpStudy/ca-bundle.crt
  4. 重新安装Composer应该就能成功了。

composer常用命令:

  1. composer self-update:
    将 Composer 自身升级到最新版本,只需要运行 self-update 命令。它将替换你的 composer.phar 文件到最新版本。
  2. composer install:
    从当前目录读取 composer.json 文件,处理了依赖关系,并把其安装到 vendor 目录下。如果当前目录下存在 composer.lock 文件,它会从此文件读取依赖版本,而不是根据 composer.json 文件去获取依赖。确保了该库的每个使用者都能得到相同的依赖版本。
  3. composer global require “fxp/composer-asset-plugin:1.1.1” :
    申明依赖,增加新的依赖包到当前目录的 composer.json 文件中。
0 0