win10使用Composer-Setup安裝Composer以及使用Composer安裝Yii2最新版

流火行者發表於2016-01-14

1:下載 ca-bundle.crt和cacert.pem

將這兩個檔案放在php目錄下

2:php.ini中新增上述兩個檔案的路徑

curl.cainfo=C:/xampp/php/ca-bundle.crt
openssl.cafile=C:/xampp/php/ca-bundle.crt

寫到最後一行就可以

3:下載Composer-Setup.exe

https://getcomposer.org/download/

在該頁面找到Composer-Setup.exe並下載安裝(要求能vpnFQ)

4:安裝如果出現錯誤

Notice: Undefined variable: caBundle in - on line 892

出現該錯誤的時候,找到錯誤路徑開啟install檔案,找到892行

紅線的地方報caBundle未定義,手動改成如下:

改完之後儲存檔案,並且退出Composer-Setup.exe(不要繼續安裝),然後重新安裝,不報錯,走完安裝過程

5:驗證安裝結果:

6:安裝Yii2

在伺服器上建立訪問目錄yii2,

在github的個人資訊的設定上生成一個token,後面建立專案的時候提示token(hidden)的時候將這個token複製上去

參照

http://www.yiiframework.com/download/

安裝Yii2的最新版本,

注意要將下面這兩行建立命令

php composer.phar global require "fxp/composer-asset-plugin:~1.1.1"
php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.6
改為:
composer global require "fxp/composer-asset-plugin:~1.1.1"
composer create-project yiisoft/yii2-app-basic basic 2.0.6
如果是advanced專案:
composer create-project yiisoft/yii2-app-advanced advanced 2.0.6

然後等待安裝,cmd顯示如下:

Microsoft Windows [版本 10.0.10240] (c) 2015 Microsoft Corporation. All rights reserved.

C:\Users\jzzq>cd C:\xampp\htdocs\yii2

C:\xampp\htdocs\yii2>php composer.phar global require "fxp/composer-asset-plugin:~1.1.1" Could not open input file: composer.phar

C:\xampp\htdocs\yii2>composer self-update You are already using composer version 03299ff075236be27be356498d6c64def973fe41.

C:\xampp\htdocs\yii2>php composer.phar global require "fxp/composer-asset-plugin:~1.1.1" Could not open input file: composer.phar

C:\xampp\htdocs\yii2>composer global require "fxp/composer-asset-plugin:~1.1.1" Changed current directory to C:/Users/jzzq/AppData/Roaming/Composer Deprecation Notice: The Composer\Package\LinkConstraint\MultiConstraint class is deprecated, use Composer\Semver\Constraint\MultiConstraint instead. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Package/LinkConstraint/MultiConstraint.php:17 Deprecation Notice: The Composer\Package\LinkConstraint\LinkConstraintInterface interface is deprecated, use Composer\Semver\Constraint\ConstraintInterface instead. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Package/LinkConstraint/LinkConstraintInterface.php:17 ./composer.json has been updated Loading composer repositories with package information Updating dependencies (including require-dev)   - Removing fxp/composer-asset-plugin (v1.0.3)   - Installing fxp/composer-asset-plugin (v1.1.1)     Downloading: 100%

Writing lock file Generating autoload files

C:\xampp\htdocs\yii2>php composer.phar create-project yiisoft/yii2-app-basic basic 2.0.6 Could not open input file: composer.phar

C:\xampp\htdocs\yii2>composer create-project yiisoft/yii2-app-basic basic 2.0.6 Installing yiisoft/yii2-app-basic (2.0.6)   - Installing yiisoft/yii2-app-basic (2.0.6)     Loading from cache

Created project in basic Loading composer repositories with package information Installing dependencies (including require-dev)   - Installing yiisoft/yii2-composer (2.0.3)     Loading from cache

  - Installing ezyang/htmlpurifier (v4.6.0)     Loading from cache

  - Installing bower-asset/jquery (2.1.4)     Loading from cache

  - Installing bower-asset/yii2-pjax (v2.0.5)     Loading from cache

  - Installing bower-asset/punycode (v1.3.2)     Loading from cache

  - Installing bower-asset/jquery.inputmask (3.1.63)     Loading from cache

  - Installing cebe/markdown (1.1.0)     Loading from cache

  - Installing yiisoft/yii2 (2.0.6)     Loading from cache

  - Installing swiftmailer/swiftmailer (v5.4.1)     Loading from cache

  - Installing yiisoft/yii2-swiftmailer (2.0.4)     Loading from cache

  - Installing yiisoft/yii2-codeception (2.0.4)     Loading from cache

  - Installing bower-asset/bootstrap (v3.3.5)     Loading from cache

  - Installing yiisoft/yii2-bootstrap (2.0.5)     Loading from cache

  - Installing yiisoft/yii2-debug (2.0.5)     Loading from cache

  - Installing bower-asset/typeahead.js (v0.10.5)     Loading from cache

  - Installing phpspec/php-diff (v1.0.2)     Loading from cache

  - Installing yiisoft/yii2-gii (2.0.4)     Loading from cache

  - Installing fzaninotto/faker (v1.5.0)     Loading from cache

  - Installing yiisoft/yii2-faker (2.0.3)     Loading from cache

fzaninotto/faker suggests installing ext-intl (*) Writing lock file Generating autoload files > yii\composer\Installer::postCreateProject chmod('runtime', 0777)...done. chmod('web/assets', 0777)...done. chmod('yii', 0755)...done.

C:\xampp\htdocs\yii2>composer create-project yiisoft/yii2-app-advanced advanced 2.0.6 Installing yiisoft/yii2-app-advanced (2.0.6)   - Installing yiisoft/yii2-app-advanced (2.0.6)     Downloading: 100%

Created project in advanced Loading composer repositories with package information Installing dependencies (including require-dev)   - Installing yiisoft/yii2-composer (2.0.3)     Loading from cache

  - Installing ezyang/htmlpurifier (v4.6.0)     Loading from cache

  - Installing cebe/markdown (1.1.0)     Loading from cache

  - Installing bower-asset/jquery (2.1.4)     Loading from cache

  - Installing bower-asset/jquery.inputmask (3.1.63)     Loading from cache

  - Installing bower-asset/punycode (v1.3.2)     Loading from cache

  - Installing bower-asset/yii2-pjax (v2.0.5)     Loading from cache

  - Installing yiisoft/yii2 (2.0.6)     Loading from cache

  - Installing swiftmailer/swiftmailer (v5.4.1)     Loading from cache

  - Installing yiisoft/yii2-swiftmailer (2.0.4)     Loading from cache

  - Installing yiisoft/yii2-codeception (2.0.4)     Loading from cache

  - Installing bower-asset/bootstrap (v3.3.5)     Loading from cache

  - Installing yiisoft/yii2-bootstrap (2.0.5)     Loading from cache

  - Installing yiisoft/yii2-debug (2.0.5)     Loading from cache

  - Installing bower-asset/typeahead.js (v0.10.5)     Loading from cache

  - Installing phpspec/php-diff (v1.0.2)     Loading from cache

  - Installing yiisoft/yii2-gii (2.0.4)     Loading from cache

  - Installing fzaninotto/faker (v1.5.0)     Loading from cache

  - Installing yiisoft/yii2-faker (2.0.3)     Loading from cache

fzaninotto/faker suggests installing ext-intl (*) Writing lock file Generating autoload files

C:\xampp\htdocs\yii2>

7:測試

 

相關文章