没有不值得去解决的问题,也没有不值得去学习的技术!

Update Yii 2 to the Latest Version with Composer: Upgrade the Yii Framework from 2.0.35 to 2.0.41.1

Update Yii 2 to the latest version by running composer update. Yii Framework has been upgraded from version 2.0.35 to 2.0.41.1.

1. Composer was already installed previously. To ensure the latest version is used, update Composer to version 2.0.12 by running composer self-update, as shown in Figure 1.

Composer was already installed previously. To ensure the latest version is used, update Composer to version 2.0.12 by running composer self-update.
Figure 1
Plaintext
PS E:\> composer self-update
Updating to version 2.0.12 (stable channel).
   Downloading (100%)
Use composer self-update --rollback to return to version 1.10.6

2. Update Yii 2 to the latest version by running composer update. Yii Framework has been upgraded from version 2.0.35 to 2.0.41.1, as shown in Figure 2.

Update Yii 2 to the latest version by running composer update. Yii Framework has been upgraded from version 2.0.35 to 2.0.41.1.
Figure 2
Plaintext
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer update
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 68 updates, 1 removal
...
- Upgrading yiisoft/yii2 (2.0.35 => 2.0.41.1)
- Upgrading yiisoft/yii2-composer (2.0.9 => 2.0.10)
- Upgrading yiisoft/yii2-debug (2.1.13 => 2.1.16)
- Upgrading yiisoft/yii2-faker (2.0.4 => 2.0.5)
- Upgrading yiisoft/yii2-httpclient (2.0.12 => 2.0.13)
...
Package flow/jsonpath is abandoned, you should avoid using it. Use softcreatr/jsonpath instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.

Seems you have upgraded Yii Framework from version 2.0.35 to 2.0.41.1.

Please check the upgrade notes for possible incompatible changes
and adjust your application code accordingly.

3. First, resolve the message related to “fxp/composer-asset-plugin”. See Figure 3.

First, resolve the message related to "fxp/composer-asset-plugin".
Figure 3
Plaintext
The "fxp/composer-asset-plugin" plugin (installed globally) was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.

4. Reference URL: https://www.yiiframework.com/doc/guide/2.0/zh-cn/structure-assets . Note: Starting from 2.0.13, both the basic and advanced application templates are configured to use asset-packagist by default. I decided to globally remove “fxp/composer-asset-plugin”. See Figure 4.

Reference URL: https://www.yiiframework.com/doc/guide/2.0/zh-cn/structure-assets . Note: Starting from 2.0.13, both the basic and advanced application templates are configured to use asset-packagist by default. I decided to globally remove "fxp/composer-asset-plugin".
Figure 4
Plaintext
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer global remove fxp/composer-asset-plugin
Changed current directory to C:/Users/Administrator/AppData/Roaming/Composer
The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
fxp/composer-asset-plugin is not required in your composer.json and has not been removed
./composer.json has been updated
The "fxp/composer-asset-plugin" plugin was skipped because it requires a Plugin API version ("^1.0") that does not match your Composer installation ("2.0.0"). You may need to run composer update with the "--no-plugins" option.
Running composer update fxp/composer-asset-plugin
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 0 updates, 1 removal
  - Removing fxp/composer-asset-plugin (v1.4.4)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Removing fxp/composer-asset-plugin (v1.4.4)
Generating autoload files
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced>

5. Run composer update again to update Yii 2 to the latest version. The message related to “fxp/composer-asset-plugin” no longer appears, but other messages still exist. See Figure 5.

Run composer update again to update Yii 2 to the latest version. The message related to "fxp/composer-asset-plugin" no longer appears, but other messages still exist.
Figure 5
Plaintext
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer update
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 0 updates, 0 removals
Package flow/jsonpath is abandoned, you should avoid using it. Use softcreatr/jsonpath instead.
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
47 packages you are using are looking for funding.
Use the `composer fund` command to find out more!

6. The package flow/jsonpath is abandoned, and you should avoid using it. Use softcreatr/jsonpath instead. I decided to uninstall flow/jsonpath and install softcreatr/jsonpath. See Figure 6.

The package flow/jsonpath is abandoned, and you should avoid using it. Use softcreatr/jsonpath instead. I decided to uninstall flow/jsonpath and install softcreatr/jsonpath.
Figure 6
Plaintext
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer remove flow/jsonpath
./composer.json has been updated
Running composer update flow/jsonpath
Loading composer repositories with package information
Updating dependencies
Lock file operations: 0 installs, 0 updates, 1 removal
  - Removing flow/jsonpath (0.5.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 0 updates, 1 removal
  - Removing flow/jsonpath (0.5.0)
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
47 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer require --prefer-dist softcreatr/jsonpath
Using version ^0.7.3 for softcreatr/jsonpath
./composer.json has been updated
Running composer update softcreatr/jsonpath
Loading composer repositories with package information
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
  - Locking softcreatr/jsonpath (0.7.3)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
  - Downloading softcreatr/jsonpath (0.7.3)
  - Installing softcreatr/jsonpath (0.7.3): Extracting archive
Package phpunit/php-token-stream is abandoned, you should avoid using it. No replacement was suggested.
Generating autoload files
48 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced>

7. The package phpunit/php-token-stream is abandoned, and you should avoid using it. No replacement was suggested. Using the dependency check `depends` command, you can find out whether a package installed in your project is being depended on by other packages, and list them. I concluded that phpunit/php-code-coverage depends on phpunit/php-token-stream; codeception/phpunit-wrapper and phpunit/phpunit depend on phpunit/php-code-coverage; codeception/codeception, codeception/lib-asserts, and codeception/verify depend on codeception/phpunit-wrapper, forming multiple layers of dependencies. I decided to keep this warning, as there is no solution for now. See Figure 7.

The package phpunit/php-token-stream is abandoned, and you should avoid using it. No replacement was suggested. Using the dependency check `depends` command, you can find out whether a package installed in your project is being depended on by other packages, and list them. I concluded that phpunit/php-code-coverage depends on phpunit/php-token-stream; codeception/phpunit-wrapper and phpunit/phpunit depend on phpunit/php-code-coverage; codeception/codeception, codeception/lib-asserts, and codeception/verify depend on codeception/phpunit-wrapper, forming multiple layers of dependencies. I decided to keep this warning, as there is no solution for now.
Figure 7
Plaintext
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer depends phpunit/php-token-stream
phpunit/php-code-coverage  7.0.14  requires  phpunit/php-token-stream (^3.1.1 || ^4.0)
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer depends phpunit/php-code-coverage
codeception/phpunit-wrapper  8.1.4   requires  phpunit/php-code-coverage (^7.0)    
phpunit/phpunit              8.5.15  requires  phpunit/php-code-coverage (^7.0.12) 
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer depends codeception/phpunit-wrapper
codeception/codeception  4.1.20  requires  codeception/phpunit-wrapper (>6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.1.1 | ^9.0)
codeception/lib-asserts  1.13.2  requires  codeception/phpunit-wrapper (>6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.3 | ^9.0)
codeception/verify       1.1.0   requires  codeception/phpunit-wrapper (>6.0.15 <6.1.0 | ^6.6.1 | ^7.7.1 | ^8.0.4)
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer depends codeception/codeception
shuijingwan/yii2-app-advanced  dev-master  requires (for development)  codeception/codeception (^4.0)
codeception/lib-innerbrowser   1.4.2       requires                    codeception/codeception (*@dev)
codeception/module-asserts     1.3.1       requires                    codeception/codeception (*@dev)
codeception/module-filesystem  1.0.3       requires                    codeception/codeception (^4.0)
codeception/module-yii2        1.1.2       requires                    codeception/codeception (^4.0)
PS E:\wwwroot\github-shuijingwan-yii2-app-advanced> composer depends phpunit/phpunit
codeception/phpunit-wrapper  8.1.4  requires  phpunit/phpunit (^8.0)
codeception/stub             3.7.0  requires  phpunit/phpunit (^8.4 | ^9.0)
codeception/verify           1.1.0  requires  phpunit/phpunit (> 6.0)

8. View the Yii Framework 2.0 upgrade notes online: https://github.com/yiisoft/yii2/blob/2.0.41.1/framework/UPGRADE.md to understand potentially incompatible changes, such as certain classes being extended whose properties and methods have been adjusted in the new version.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系