1、之前已安装 Composer,为确保使用最新版本。可以通过运行 composer self-update 来更新 Composer 至版本 1.9.2,如图1
PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer self-update Updating to version 1.9.2 (stable channel). Downloading (100%) Use composer self-update --rollback to return to version 1.8.3
2、通过运行 composer update 来更新 Yii 2 至最新版本,已将 Yii Framework 从 2.0.15.1 版本升级到 2.0.31,如图2
PS E:/wwwroot/github-shuijingwan-yii2-app-advanced> composer update Loading composer repositories with package information Updating dependencies (including require-dev) Package operations: 7 installs, 42 updates, 5 removals - Removing symfony/process (v4.2.2) - Removing symfony/contracts (v1.0.2) - Removing guzzlehttp/promises (v1.3.1) - Removing guzzlehttp/guzzle (6.3.3) - Removing facebook/webdriver (1.6.0) - Updating yiisoft/yii2-composer (2.0.7 => 2.0.8): Loading from cache - Updating bower-asset/jquery (3.2.1 => 3.4.1): Loading from cache - Updating bower-asset/bootstrap (v3.4.0 => v3.4.1): Loading from cache - Updating ezyang/htmlpurifier (v4.10.0 => v4.12.0): Loading from cache - Updating cebe/markdown (1.1.2 => 1.2.1): Loading from cache - Updating yiisoft/yii2 (2.0.15.1 => 2.0.31): Loading from cache - Updating yiisoft/yii2-bootstrap (2.0.9 => 2.0.10): Loading from cache - Updating yii2tech/ar-softdelete (1.0.3 => 1.0.4): Downloading (100%) - Updating sebastian/exporter (3.1.0 => 3.1.2): Loading from cache - Updating sebastian/environment (4.0.2 => 4.2.3): Downloading (100%) - Updating sebastian/diff (3.0.1 => 3.0.2): Downloading (100%) - Updating phpunit/php-timer (2.0.0 => 2.1.2): Downloading (100%) - Updating theseer/tokenizer (1.1.0 => 1.1.3): Loading from cache - Updating phpunit/php-token-stream (3.0.1 => 3.1.1): Downloading (100%) - Updating symfony/polyfill-ctype (v1.10.0 => v1.13.1): Loading from cache - Updating webmozart/assert (1.4.0 => 1.6.0): Loading from cache - Updating phpdocumentor/reflection-common (1.0.1 => 2.0.0): Loading from cache - Updating phpdocumentor/type-resolver (0.4.0 => 1.0.1): Loading from cache - Updating phpdocumentor/reflection-docblock (4.3.0 => 4.3.4): Loading from cache - Updating doctrine/instantiator (1.1.0 => 1.3.0): Loading from cache - Updating phpspec/prophecy (1.8.0 => 1.10.1): Loading from cache - Updating myclabs/deep-copy (1.8.1 => 1.9.4): Loading from cache - Updating phpunit/phpunit (7.5.2 => 7.5.20): Downloading (100%) - Updating symfony/yaml (v4.2.2 => v4.4.2): Loading from cache - Updating codeception/phpunit-wrapper (7.6.1 => 7.8.0): Downloading (100%) - Updating codeception/stub (2.0.4 => 2.1.0): Downloading (100%) - Updating symfony/polyfill-mbstring (v1.10.0 => v1.13.1): Loading from cache - Updating symfony/dom-crawler (v4.2.2 => v4.4.2): Loading from cache - Updating symfony/css-selector (v4.2.2 => v4.4.2): Loading from cache - Updating symfony/browser-kit (v4.2.2 => v4.4.2): Downloading (100%) - Installing psr/container (1.0.0): Loading from cache - Installing symfony/event-dispatcher-contracts (v1.1.7): Loading from cache - Updating symfony/event-dispatcher (v4.2.2 => v4.4.2): Loading from cache - Installing symfony/service-contracts (v2.0.1): Downloading (100%) - Installing symfony/polyfill-php73 (v1.13.1): Loading from cache - Updating symfony/console (v4.2.2 => v4.4.2): Loading from cache - Updating symfony/finder (v4.2.2 => v4.4.2): Loading from cache - Updating ralouphie/getallheaders (2.0.5 => 3.0.3): Loading from cache - Updating guzzlehttp/psr7 (1.5.2 => 1.6.1): Loading from cache - Updating codeception/base (2.5.2 => 2.5.6): Downloading (100%) - Updating hprose/hprose (v2.0.37 => v2.0.39): Downloading (100%) - Updating yiisoft/yii2-httpclient (2.0.7 => 2.0.12): Downloading (100%) - Updating fzaninotto/faker (v1.8.0 => v1.9.1): Loading from cache - Installing symfony/polyfill-php72 (v1.13.1): Loading from cache - Installing symfony/polyfill-intl-idn (v1.13.1): Loading from cache - Installing symfony/polyfill-iconv (v1.13.1): Loading from cache - Updating doctrine/lexer (v1.0.1 => 1.2.0): Downloading (100%) - Updating egulias/email-validator (2.1.7 => 2.1.14): Loading from cache - Updating swiftmailer/swiftmailer (v6.1.3 => v6.2.3): Loading from cache symfony/event-dispatcher-contracts suggests installing psr/event-dispatcher symfony/service-contracts suggests installing symfony/service-implementation Writing lock file Generating autoload files Seems you have upgraded Yii Framework from version 2.0.15.1 to 2.0.31. Please check the upgrade notes for possible incompatible changes and adjust your application code accordingly. Upgrade from Yii 2.0.30 ----------------------- * `yii/helpers/BaseInflector::slug()` now ensures there is no repeating $replacement string occurrences. In case you rely on Yii 2.0.16 - 2.0.30 behavior, consider replacing `Inflector` with your own implementation. Upgrade from Yii 2.0.20 ----------------------- * `yii/db/Query::select()` and `addSelect()` now normalize the format that columns are stored in when saving them to `$this->select`, so code that works directly with that property may need to be modified. For the following code: ```php $a = $query->select('*'); $b = $query->select('id, name'); ``` The value was stored as is i.e. ```php // a ['*'] // b ['id', 'name'] ``` Now it is stored as ```php // a ['*' => '*'] // b ['id' => 'id', 'name' => 'name'] ``` Upgrade from Yii 2.0.16 ----------------------- * In case you have extended the `yii/web/DbSession` class you should check if your custom implementation is compatible with the new `yii/web/DbSession::$fields` attribute. Especially when overriding the `yii/web/DbSession::writeSession($id, $data)` function. Upgrade from Yii 2.0.15 ----------------------- * Updated dependency to `cebe/markdown` to version `1.2.x`. If you need stick with 1.1.x, you can specify that in your `composer.json` by adding the following line in the `require` section: ```json "cebe/markdown": "~1.1.0", ``` * `yii/mutex/Mutex::acquire()` no longer returns `true` if lock is already acquired by the same component in the same process. Make sure that you're not trying to acquire the same lock multiple times in a way that may create infinite loops, fo r example: ```php if (Yii::$app->mutex->acquire('test')) { while (!Yii::$app->mutex->acquire('test')) { // `Yii::$app->mutex->acquire('test')` will always return `false` here, since lock is already acquired } } ``` * Formatter methods `asInteger`, `asDecimal`, `asPercent`, and `asCurrency` are using now inner fallback methods to ha ndle very big number values to counter inner PHP casting and floating point number presentation issues. Make sure to prov ide such values as string numbers. * Active Record relations are now being reset when corresponding key fields are changed. If you have relied on the fac t that relations are never reloaded you have to adjust your code. You can find the upgrade notes for all versions online at: https://github.com/yiisoft/yii2/blob/2.0.31/framework/UPGRADE.md
3、在线查看 Yii Framework 2.0 升级说明:https://github.com/yiisoft/yii2/blob/2.0.31/framework/UPGRADE.md ,了解可能不兼容的更改,比如,扩展了某些类,而这些类的属性与方法在新版本中有所调整。如图3
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/181472.html