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


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並下載安裝(要求能vpn翻牆)

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:測試

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM