yii2 项目安装及升级

Yii Framework是使用广泛的高性能PHP WEB框架,易于上手,功能丰富。以yii2-app-advanced模板为例演示项目的部署及升级方法。

yii2 安装

php composer.phar create-project yiisoft/yii2-app-advanced advanced-app

参考:https://www.yiiframework.com/doc/guide/2.0/en/start-installation#installing-via-composer

yii2 升级

The simple way to upgrade Yii, for example to version 2.0.16 (replace this with the version you want) will be running composer require:

composer require "yiisoft/yii2:~2.0.16" --update-with-dependencies

也可使用composer update:

php composer.phar update yiisoft/yii2 yiisoft/yii2-composer bower-asset/jquery.inputmask

升级yii2 组件

composer update

将解析composer.json文件,安装所有依赖到最新版本。比较危险,线上服务谨慎操作!

仅升级指定依赖项:

composer update vendor/package

20191012更新

执行更新时遇到以下错误:

[ErrorException]                                                             
  "continue" targeting switch is equivalent to "break". Did you mean to use "  
  continue 2"? 

此时需要更新composer.phar:

curl -sS https://getcomposer.org/installer | php

参考:https://github.com/yiisoft/yii2/blob/2.0.16/framework/UPGRADE.md