使用composer遇到的问题及解决方法

  能够尝试利用composer下载Yii框架,编辑composer.json文件:php

{
    "require":{
        "yiisoft/yii2":"~2.0.0"
    }
}

 

  而后在这个包含composer.json文件的目录下执行命令:jquery

composer install

  而后就等待下载完成git

 

问题零:Your requirements could not be resolved to an installable set of packages.

  若是出现下面这种状况:github

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  须要安装一个composer资源插件,运行命令安装便可:json

composer global require "fxp/composer-asset-plugin:^1.4.1"

  

 

问题一:proc_get_status() has been disabled for security reasons 

  若是出现下面这种状况:api

[ErrorException]
proc_get_status() has been disabled for security reasons
PHP Fatal error: Uncaught exception 'ErrorException' with message 'proc_get_status() has been disabled for security reasons'
in phar:///usr/local/bin/composer/vendor/symfony/process/Process.php:1279

  这是由于安全缘由,将proc_get_status函数禁用了,能够经过编辑php的配置文件php.ini,搜索proc_get_status,将他从disable_functions中删除便可。浏览器

 

 

问题二:须要输入token

  若是是第一次使用composer,那么在下载文件yii框架的过程当中,有几项须要输入token,以下图:安全

[root@localhost tmp]# composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)

Could not fetch https://api.github.com/repos/jquery/jquery-dist, please create a GitHub OAuth token to go over the API rate limit
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+localhost.localdomain+2018-02-22+1945
to retrieve a token. It will be stored in "/root/.composer/auth.json" for future use by Composer.
Token (hidden):

  只要粘贴上面的URL到浏览器中打开,而后生成一个token,而后复制这个新的token,在命令行中须要token的地方输入该token便可,该token会存储在用户家目录/.composer/auth.json中:bash

{
    "bitbucket-oauth": {},
    "github-oauth": {
        "github.com": "6ad4ef7375b1fb9........"},
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {}
}

  此后能够不用再输入token了,composer会自动去auth.json中找。yii2

相关文章
相关标签/搜索