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

Analyzing the Loss of the guzzlehttp guzzle Package After Updating Yii 2 to the Latest Version With Composer

In a branch where the Yii 2 version is still 2.0.15.1, using the dependency check depends command can determine whether a package installed in your project is being depended on by other packages, and lists them. The conclusion: guzzlehttp/promises depends on guzzlehttp/guzzle, guzzlehttp/guzzle depends on codeception/base, and codeception/base depends on yiisoft/yii2-app-advanced

1. Reference: Upgrading Yii Framework from version 2.0.15.1 to 2.0.31

2. Errors occurred in some programs using: \GuzzleHttp\json_encode, \GuzzleHttp\json_decode. After final analysis, the reason is that the directories: /vendor/guzzlehttp/guzzle, /vendor/guzzlehttp/promises no longer exist. See Figure 1.

Errors occurred in some programs using: \GuzzleHttp\json_encode, \GuzzleHttp\json_decode. After final analysis, the reason is that the directories: /vendor/guzzlehttp/guzzle, /vendor/guzzlehttp/promises no longer exist
Figure 1

3. After careful analysis, I found that in step 2 of the referenced URL, running composer update uninstalled: guzzlehttp/promises, guzzlehttp/guzzle, as shown in Figure 2.

After careful analysis, I found that in step 2 of the referenced URL, running composer update uninstalled: guzzlehttp/promises, guzzlehttp/guzzle
Figure 2

4. The issue in step 2 was ultimately resolved by using the Yii helper class Json: https://www.yiiframework.com/doc/api/2.0/yii-helpers-json, performing the corresponding replacement operations.

Plaintext

\GuzzleHttp\json_decode
\yii\helpers\Json::decode

\GuzzleHttp\json_encode
\yii\helpers\Json::encode

5. In a branch where the Yii 2 version is still 2.0.15.1, using the dependency check depends command can determine whether a package installed in your project is being depended on by other packages, and lists them. The conclusion: guzzlehttp/promises depends on guzzlehttp/guzzle, guzzlehttp/guzzle depends on codeception/base, and codeception/base depends on yiisoft/yii2-app-advanced. See Figure 3.

In a branch where the Yii 2 version is still 2.0.15.1, using the dependency check depends command can determine whether a package installed in your project is being depended on by other packages, and lists them. The conclusion: guzzlehttp/promises depends on guzzlehttp/guzzle, guzzlehttp/guzzle depends on codeception/base, and codeception/base depends on yiisoft/yii2-app-advanced
Figure 3
Plaintext
PS E:\wwwroot\pcs-api-feature-config-group-task-step> ./yii

This is Yii version 2.0.15.1.

The following commands are available:

- asset                        Allows you to combine and compress your JavaScript and CSS files.
    asset/compress (default)   Combines and compresses the asset files according to the given configuration.
    asset/template             Creates template of configuration file for [[actionCompress]].

- cache                        Allows you to flush cache.
    cache/flush                Flushes given cache components.
    cache/flush-all            Flushes all caches registered in the system.
    cache/flush-schema         Clears DB schema cache for a given connection component.
    cache/index (default)      Lists the caches that can be flushed.

- cmc-console-user             Framework service console users
    cmc-console-user/sync      Sync framework service console user model (Http) to framework service console user model (R
                               edis)

- config-column-user           Column personnel configuration
    config-column-user/sync    Sync framework service console user model (Http) to column personnel configuration model (MySQL)

- fixture                      Manages fixture data loading and unloading.
    fixture/load (default)     Loads the specified fixture data.
    fixture/unload             Unloads the specified fixtures.

- gii                          This is the command line version of Gii - a code generator.
    gii/controller             Controller Generator
    gii/crud                   CRUD Generator
    gii/extension              Extension Generator
    gii/form                   Form Generator
    gii/index (default)
    gii/model                  Model Generator
    gii/module                 Module Generator

- help                         Provides help information about console commands.
    help/index (default)       Displays available commands or the detailed information
    help/list                  List all available controllers and actions in machine readable format.
    help/list-action-options   List all available options for the $action in machine readable format.
    help/usage                 Displays usage information for $action.

- log                          Log
    log/delete                 Deletion of logs

- message                      Extracts messages to be translated from source files.
    message/config             Creates a configuration file for the "extract" command using command line options
                               specified.
    message/config-template    Creates a configuration file template for the "extract" command.
    message/extract (default)  Extracts messages to be translated from source code.

- migrate                      Manages application migrations.
    migrate/create             Creates a new migration.
    migrate/down               Downgrades the application by reverting old migrations.
    migrate/fresh              Truncates the whole database and starts the migration from the beginning.
    migrate/history            Displays the migration history.
    migrate/mark               Modifies the migration history to the specified version.
    migrate/new                Displays the un-applied new migrations.
    migrate/redo               Redoes the last few migrations.
    migrate/to                 Upgrades or downgrades till the specified version.
    migrate/up (default)       Upgrades the application by applying new migrations.

- plan-task                    Topic selection task
    plan-task/close            Close topic selection task

- serve                        Runs PHP built-in web server.
    serve/index (default)      Runs PHP built-in web server.


To see the help of each command, enter:

  yii help 

PS E:\wwwroot\pcs-api-feature-config-group-task-step> composer depends guzzlehttp/promises
guzzlehttp/guzzle  6.3.3  requires  guzzlehttp/promises (^1.0)
PS E:\wwwroot\pcs-api-feature-config-group-task-step> composer depends guzzlehttp/guzzle
codeception/base  2.5.2  requires  guzzlehttp/guzzle (>=4.1.4 <7.0)
PS E:\wwwroot\pcs-api-feature-config-group-task-step> composer depends codeception/base
shuijingwan/yii2-app-advanced  dev-feature-config-group-task-step  requires (for development)  codeception/base (^2.2.3)


6. After checking the composer.json of two versions of codeception/base respectively, upgrading Yii Framework from version 2.0.15.1 to 2.0.31 consequently caused codeception/base to upgrade from version 2.5.2 to 2.5.6, and version 2.5.6 of codeception/base has already abandoned the dependency on guzzlehttp/guzzle. Observation shows that the dependency type of codeception/base is: require-dev, therefore, it can only be used in the development stage, not in the production stage.

Plaintext

    "require-dev": {
        "yiisoft/yii2-debug": "~2.0.0",
        "yiisoft/yii2-gii": "~2.0.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/base": "^2.2.3",
        "codeception/verify": "~0.3.1"
    },

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

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

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

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

关于我  ·  GitHub  ·  邮件联系