使用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

相關文章
相關標籤/搜索