yii2使用composer安装出错,github授权问题

2020年11月22日 392 本文共1332字,预计阅读时间4分钟

问题:

在终端输入

composer create-project yiisoft/yii2-app-advanced yii2-advanced –prefer-dist

报错

➜ Yii2.0 composer create-project yiisoft/yii2-app-advanced yii2-advanced –prefer-dist

Installing yiisoft/yii2-app-advanced (2.0.12)
– Installing yiisoft/yii2-app-advanced (2.0.12): Downloading (100%)
Created project in yii2-advanced
Loading composer repositories with package information
Updating dependencies (including require-dev)

[Composer\Repository\InvalidRepositoryException]
No valid bower.json was found in any branch or tag of https://github.com/bestiejs/punycode.js.git, could not load a package from it.

create-project [-s|–stability STABILITY] [–prefer-source] [–prefer-dist] [–repository REPOSITORY] [–repository-url REPOSITORY-URL] [–dev] [–no-dev] [–no-custom-installers] [–no-scripts] [–no-progress] [–no-secure-http] [–keep-vcs] [–no-install] [–ignore-platform-reqs] [–] [<package>] [<directory>] [<version>]

解决方案:

直接编辑yii2-advanced文件夹composer.json文件
vi yii2-advanced/composer.json

然后添加github的授权

“config”: {
        “process-timeout”: 1800
    },
改为

“config”: {
        “process-timeout”: 1800,
        “github-oauth”: {
          “github.com”: “此处输入您的github授权码”
          }
    },

保存文件,运行以下命令即可完成yii2框架的导入

cd yii2-advanced
composer update

如何获取github的授权码??
https://github.com/settings/tokens

点击此链接  –>  点击右上角Generate new token  –> 在Token description中输入”yii composer install token”  

–>  点击Generate token即可创建新的github授权码

Token description中可以随意输入描述