可以嘗試利用composer下載Yii框架,編輯composer.json文件:
{
"require":{
"yiisoft/yii2":"~2.0.0"
}
}
然后在這個包含composer.json文件的目錄下執行命令:
composer install
然后就等待下載完成
問題零:Your requirements could not be resolved to an installable set of packages.
如果出現下面這種情況:
Loading composer repositories with package information Updating dependencies (including require-dev) Your requirements could not be resolved to an installable set of packages.
需要安裝一個composer資源插件,運行命令安裝即可:
composer global require "fxp/composer-asset-plugin:^1.4.1"
問題一:proc_get_status() has been disabled for security reasons
如果出現下面這種情況:
[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中:
{
"bitbucket-oauth": {},
"github-oauth": {
"github.com": "6ad4ef7375b1fb9........"},
"gitlab-oauth": {},
"gitlab-token": {},
"http-basic": {}
}
此后可以不用再輸入token了,composer會自動去auth.json中找。
