若是尚未安裝 Composer,你能夠按 getcomposer.org 中的方法安裝。 在 Linux 和 Mac OS X 中,你能夠運行以下命令:php
curl -sS https://getcomposer.org/installer | phpcss
mv composer.phar /usr/local/bin/composerhtml
步驟:jquery
1、打開終端git
2、安裝composer:github
一、終端輸入:curl -sS https://getcomposer.org/installer | phpweb
composer安裝成功 npm
二、終端輸入:mv composer.phar /usr/local/bin/composer json
將composer.phar移動到 /usr/local/bin/composer支持全局訪問composer命令 bootstrap
3、驗證方法:(注意:須要有訪問權限,不然會提示沒有權限訪問)
輸入:composer -v
3、安裝Yii2
Composer 安裝後,切換到一個可經過 Web 訪問的目錄,執行以下命令便可安裝 Yii :
composer global require "fxp/composer-asset-plugin:^1.2.0"
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
第一條命令安裝 Composer asset plugin, 它是經過 Composer 管理 bower 和 npm 包所必須的,此命令全局生效,一勞永逸。
第二條命令會將 Yii 安裝在名爲 basic
的目錄中。若是你想使用其它目錄名稱,你能夠選擇其餘目錄名稱。
一、終端輸入:composer global require "fxp/composer-asset-plugin:^1.2.0"
若是你沒有安裝Gii該過程會提示你是否安裝,安裝便可(如下我的項目名稱cqy,固然也能夠修改爲本身想要的項目名稱)
二、終端輸入:composer create-project --prefer-dist yiisoft/yii2-app-basic cqy
若是出現如下提示:
說明你權限不夠,輸入:sudo -s,提供root權限
有了權限以後從新輸入命令,當進行到一半的時候發現須要token
token命令的話須要Github帳號來獲取
三、獲取token
在使用github獲取數據的時候,須要註冊一個github帳戶
在帳戶 Account -->Setting 點擊後頁面刷新後, 點擊 Personal access tokens, 點擊Generate new Token按鈕 生成token
獲取到token後輸入便可繼續安裝,以下:
Token (hidden): Token stored successfully. Package operations: 59 installs, 0 updates, 0 removals - Installing yiisoft/yii2-composer (2.0.5): Downloading (100%) - Installing swiftmailer/swiftmailer (v5.4.7): Downloading (100%) - Installing bower-asset/jquery (2.2.4): Downloading (100%) - Installing bower-asset/yii2-pjax (v2.0.6): Downloading (100%) - Installing bower-asset/punycode (v1.3.2): Downloading (100%) - Installing cebe/markdown (1.1.1): Downloading (100%) - Installing ezyang/htmlpurifier (v4.9.2): Downloading (100%) - Installing bower-asset/jquery.inputmask (3.3.5):Downloading (100%) ) - Installing yiisoft/yii2 (2.0.11.2): Downloading (100%) - Installing yiisoft/yii2-swiftmailer (2.0.6): Downloading (100%) - Installing bower-asset/bootstrap (v3.3.7): Downloading (100%) - Installing yiisoft/yii2-bootstrap (2.0.6): Downloading (100%) - Installing yiisoft/yii2-debug (2.0.9): Downloading (100%) - Installing bower-asset/typeahead.js (v0.11.1): Downloading (100%) - Installing phpspec/php-diff (v1.1.0): Downloading (100%) - Installing yiisoft/yii2-gii (2.0.5): Downloading (100%) - Installing fzaninotto/faker (v1.6.0): Downloading (100%) - Installing yiisoft/yii2-faker (2.0.3): Downloading (100%) - Installing psr/log (1.0.2): Downloading (100%) - Installing symfony/debug (v3.2.7): Downloading (100%) - Installing symfony/polyfill-mbstring (v1.3.0): Downloading (100%) - Installing symfony/console (v3.2.7): Downloading (100%) - Installing stecman/symfony-console-completion (0.7.0): Downloading (100%) - Installing sebastian/diff (1.4.1): Downloading (100%) - Installing sebastian/recursion-context (2.0.0): Downloading (100%) - Installing sebastian/exporter (2.0.0): Downloading (100%) - Installing sebastian/comparator (1.2.4): Downloading (100%) - Installing behat/gherkin (v4.4.5): Downloading (100%) - Installing symfony/dom-crawler (v3.2.7): Downloading (100%) - Installing symfony/css-selector (v3.2.7): Downloading (100%) - Installing symfony/browser-kit (v3.2.7): Downloading (100%) - Installing symfony/yaml (v3.2.7): Downloading (100%) - Installing symfony/event-dispatcher (v3.2.7): Downloading (100%) - Installing symfony/finder (v3.2.7): Downloading (100%) - Installing psr/http-message (1.0.1): Downloading (100%) - Installing guzzlehttp/psr7 (1.4.2): Downloading (100%) - Installing sebastian/version (2.0.1): Downloading (100%) - Installing sebastian/environment (2.0.0): Downloading (100%) - Installing sebastian/code-unit-reverse-lookup (1.0.1): Downloading (100%) - Installing phpunit/php-token-stream (1.4.11): Downloading (100%) - Installing phpunit/php-text-template (1.2.1): Downloading (100%) - Installing phpunit/php-file-iterator (1.4.2): Downloading (100%) - Installing phpunit/php-code-coverage (4.0.8): Downloading (100%) - Installing sebastian/resource-operations (1.0.0): Downloading (100%) - Installing sebastian/object-enumerator (2.0.1): Downloading (100%) - Installing sebastian/global-state (1.1.1): Downloading (100%) - Installing doctrine/instantiator (1.0.5): Downloading (100%) - Installing phpunit/phpunit-mock-objects (3.4.3):Downloading (100%) ) - Installing phpunit/php-timer (1.0.9): Downloading (100%) - Installing webmozart/assert (1.2.0): Downloading (100%) - Installing phpdocumentor/reflection-common (1.0): Downloading (100%) - Installing phpdocumentor/type-resolver (0.2.1): Downloading (100%) - Installing phpdocumentor/reflection-docblock (3.1.1): Downloading (100%) - Installing phpspec/prophecy (v1.7.0): Downloading (100%) - Installing myclabs/deep-copy (1.6.1): Downloading (100%) - Installing phpunit/phpunit (5.7.19): Downloading (100%) - Installing codeception/base (2.2.10): Downloading (100%) - Installing codeception/verify (0.3.3): Downloading (100%) - Installing codeception/specify (0.4.6): Downloading (100%) symfony/console suggests installing symfony/filesystem () symfony/console suggests installing symfony/process () symfony/browser-kit suggests installing symfony/process () symfony/event-dispatcher suggests installing symfony/dependency-injection () symfony/event-dispatcher suggests installing symfony/http-kernel () phpunit/php-code-coverage suggests installing ext-xdebug (^2.5.1) sebastian/global-state suggests installing ext-uopz (*) phpunit/phpunit suggests installing phpunit/php-invoker (~1.1) phpunit/phpunit suggests installing ext-xdebug (*) codeception/base suggests installing flow/jsonpath (For using JSONPath in REST module) codeception/base suggests installing phpseclib/phpseclib (for SFTP option in FTP Module) codeception/base suggests installing league/factory-muffin (For DataFactory module) codeception/base suggests installing league/factory-muffin-faker (For Faker support in DataFactory module) codeception/base suggests installing symfony/phpunit-bridge (For phpunit-bridge support) Writing lock file Generating autoload files > yii\composer\Installer::postCreateProject chmod('runtime', 0777)...done. chmod('web/assets', 0777)...done. chmod('yii', 0755)...done.
安裝成功!