分类
Linux PHP

linux上使用composer安装yii2

安装composer

1.下载安装脚本 - composer-setup.php - 到当前目录
php -r “copy(‘https://install.phpcomposer.com/installer’, ‘composer-setup.php’);”
2.执行安装过程
php composer-setup.php
3.删除安装脚本
php -r “unlink(‘composer-setup.php’);”
4.全局配置(根据你linux环境的实际情况)
mv composer.phar /usr/local/bin/composer

以上就完成了composer的安装
可以在命令行中输入composer看一下

安装yii2

cd到你的项目目录 就直接下载吧

1.基础版本

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

2.高级版本

composer create-project --prefer-dist --stability=dev yiisoft/yii2-app-advanced yii2

如果下载失败,你就翻墙吧,我是翻墙下载的

安装过程

root@iZuf625p95hhdjeelpz4vnZ:/www/wwwroot/myproject# composer create-project –prefer-dist yiisoft/yii2-app-advanced advanced
Installing yiisoft/yii2-app-advanced (2.0.32)
– Installing yiisoft/yii2-app-advanced (2.0.32): Loading from cache
Created project in advanced
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 66 installs, 0 updates, 0 removals
– Installing yiisoft/yii2-composer (2.0.8): Loading from cache
– Installing sebastian/diff (1.4.3): Loading from cache
– Installing sebastian/recursion-context (2.0.0): Loading from cache
– Installing sebastian/exporter (2.0.0): Loading from cache
– Installing sebastian/comparator (1.2.4): Loading from cache
– Installing sebastian/version (2.0.1): Loading from cache
– Installing sebastian/code-unit-reverse-lookup (1.0.1): Loading from cache
– Installing phpunit/php-text-template (1.2.1): Loading from cache
– Installing phpunit/php-file-iterator (1.4.5): Loading from cache
– Installing phpunit/php-token-stream (1.4.12): Loading from cache
– Installing sebastian/environment (2.0.0): Loading from cache
– Installing phpunit/php-code-coverage (4.0.8): Loading from cache
– Installing sebastian/resource-operations (1.0.0): Loading from cache
– Installing doctrine/instantiator (1.0.5): Loading from cache
– Installing phpunit/php-timer (1.0.9): Loading from cache
– Installing symfony/polyfill-ctype (v1.14.0): Loading from cache
– Installing webmozart/assert (1.7.0): Loading from cache
– Installing phpdocumentor/reflection-common (1.0.1): Loading from cache
– Installing phpdocumentor/type-resolver (0.4.0): Loading from cache
– Installing phpdocumentor/reflection-docblock (3.3.2): Loading from cache
– Installing phpspec/prophecy (v1.10.2): Loading from cache
– Installing myclabs/deep-copy (1.7.0): Loading from cache
– Installing sebastian/global-state (1.1.1): Loading from cache
– Installing sebastian/object-enumerator (2.0.1): Loading from cache
– Installing symfony/yaml (v3.4.38): Loading from cache
– Installing phpunit/phpunit-mock-objects (3.4.4): Loading from cache
– Installing phpunit/phpunit (5.7.27): Loading from cache
– Installing codeception/phpunit-wrapper (6.0.18): Loading from cache
– Installing codeception/verify (0.5.0): Loading from cache
– Installing bower-asset/jquery (3.4.1): Loading from cache
– Installing bower-asset/bootstrap (v3.4.1): Loading from cache
– Installing bower-asset/yii2-pjax (2.0.7.1): Loading from cache
– Installing bower-asset/punycode (v1.3.2): Loading from cache
– Installing bower-asset/inputmask (3.3.11): Loading from cache
– Installing cebe/markdown (1.2.1): Loading from cache
– Installing ezyang/htmlpurifier (v4.12.0): Loading from cache
– Installing yiisoft/yii2 (2.0.32): Loading from cache
– Installing yiisoft/yii2-bootstrap (2.0.10): Downloading (100%)
– Installing swiftmailer/swiftmailer (v5.4.12): Loading from cache
– Installing yiisoft/yii2-swiftmailer (2.0.7): Loading from cache
– Installing opis/closure (3.5.1): Loading from cache
– Installing yiisoft/yii2-debug (2.1.13): Loading from cache
– Installing phpspec/php-diff (v1.1.0): Loading from cache
– Installing yiisoft/yii2-gii (2.1.4): Loading from cache
– Installing fzaninotto/faker (v1.9.1): Loading from cache
– Installing yiisoft/yii2-faker (2.0.4): Loading from cache
– Installing codeception/stub (2.1.0): Loading from cache
– Installing behat/gherkin (v4.6.1): Downloading (100%)
– Installing symfony/css-selector (v3.4.38): Downloading (100%)
– Installing symfony/event-dispatcher (v3.4.38): Loading from cache
– Installing symfony/polyfill-mbstring (v1.14.0): Loading from cache
– Installing psr/log (1.1.2): Loading from cache
– Installing symfony/debug (v3.4.38): Downloading (100%)
– Installing symfony/console (v3.4.38): Downloading (100%)
– Installing symfony/finder (v3.4.38): Downloading (100%)
– Installing ralouphie/getallheaders (3.0.3): Downloading (100%)
– Installing psr/http-message (1.0.1): Downloading (100%)
– Installing guzzlehttp/psr7 (1.6.1): Downloading (100%)
– Installing codeception/lib-asserts (1.2.0): Downloading (100%)
– Installing codeception/codeception (4.1.1): Downloading (100%)
– Installing codeception/module-asserts (1.1.1): Downloading (100%)
– Installing symfony/dom-crawler (v3.4.38): Downloading (100%)
– Installing symfony/browser-kit (v3.4.38): Downloading (100%)
– Installing codeception/lib-innerbrowser (1.3.1): Downloading (100%)
– Installing codeception/module-yii2 (1.1.0): Downloading (100%)
– Installing codeception/module-filesystem (1.0.2): Downloading (100%)
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 (
)
symfony/event-dispatcher suggests installing symfony/dependency-injection
symfony/event-dispatcher suggests installing symfony/http-kernel
symfony/console suggests installing symfony/lock
symfony/console suggests installing symfony/process
guzzlehttp/psr7 suggests installing zendframework/zend-httphandlerrunner (Emit PSR-7 responses)
codeception/codeception suggests installing hoa/console (For interactive console functionality)
codeception/codeception suggests installing codeception/specify (BDD-style code blocks)
codeception/codeception suggests installing symfony/phpunit-bridge (For phpunit-bridge support)
codeception/codeception suggests installing stecman/symfony-console-completion (For BASH autocompletion)
symfony/browser-kit suggests installing symfony/process
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files

Yii初始化

root@iZuf625p95hhdjeelpz4vnZ:/www/wwwroot/myproject/advanced# ./init
Yii Application Initialization Tool v1.0

Which environment do you want the application to be initialized in?

[0] Development
[1] Production

Your choice [0-1, or “q” to quit] 0

Initialize the application under ‘Development’ environment? [yes|no] yes

Start initialization …

generate console/config/main-local.php
generate console/config/test-local.php
generate console/config/params-local.php
generate backend/web/index.php
generate backend/web/index-test.php
generate backend/web/robots.txt
generate backend/config/main-local.php
generate backend/config/test-local.php
generate backend/config/params-local.php
generate backend/config/codeception-local.php
generate yii_test
generate yii_test.bat
generate common/config/main-local.php
generate common/config/test-local.php
generate common/config/params-local.php
generate common/config/codeception-local.php
generate yii
generate frontend/web/index.php
generate frontend/web/index-test.php
generate frontend/web/robots.txt
generate frontend/config/main-local.php
generate frontend/config/test-local.php
generate frontend/config/params-local.php
generate frontend/config/codeception-local.php
generate cookie validation key in backend/config/main-local.php
generate cookie validation key in common/config/codeception-local.php
generate cookie validation key in frontend/config/main-local.php
chmod 0777 backend/runtime
chmod 0777 backend/web/assets
chmod 0777 console/runtime
chmod 0777 frontend/runtime
chmod 0777 frontend/web/assets
chmod 0755 yii
chmod 0755 yii_test

… initialization completed.

发表评论

电子邮件地址不会被公开。 必填项已用*标注