基于 Composer 更新 Yii 2 至最新版本后,软件包:guzzlehttp guzzle 的丢失的分析

1、参考网址:https://www.shuijingwanwq.com/2020/01/19/3869/ ,将 Yii Framework 从 2.0.15.1 版本升级到 2.0.31

2、在一些使用了:/GuzzleHttp/json_encode、/GuzzleHttp/json_decode 的程序中报错,最终分析发现,原因在于,目录:/vendor/guzzlehttp/guzzle、/vendor/guzzlehttp/promises 已经不存在。如图1

在一些使用了:/GuzzleHttp/json_encode、/GuzzleHttp/json_decode 的程序中报错,最终分析发现,原因在于,目录:/vendor/guzzlehttp/guzzle、/vendor/guzzlehttp/promises 已经不存在

图1

3、仔细分析后,发现参考网址中的第 2 个步骤,运行 composer update 时,卸载了:guzzlehttp/promises、guzzlehttp/guzzle,如图2

仔细分析后,发现参考网址中的第 2 个步骤,运行 composer update 时,卸载了:guzzlehttp/promises、guzzlehttp/guzzle

图2

4、步骤 2 的问题,最终通过 Yii 帮助类 Json: https://www.yiiframework.com/doc/api/2.0/yii-helpers-json 得以解决,执行相应的替换操作

/GuzzleHttp/json_decode
/yii/helpers/Json::decode

/GuzzleHttp/json_encode
/yii/helpers/Json::encode

5、在一个 Yii 2 版本仍然为:2.0.15.1 的分支中,使用 依赖性检测 depends 命令可以查出已安装在你项目中的某个包,是否正在被其它的包所依赖,并列出他们。得出结论:guzzlehttp/promises 依赖于 guzzlehttp/guzzle,guzzlehttp/guzzle 依赖于 codeception/base,codeception/base 依赖于 yiisoft/yii2-app-advanced。如图3

在一个 Yii 2 版本仍然为:2.0.15.1 的分支中,使用 依赖性检测 depends 命令可以查出已安装在你项目中的某个包,是否正在被其它的包所依赖,并列出他们。得出结论:guzzlehttp/promises 依赖于 guzzlehttp/guzzle,guzzlehttp/guzzle 依赖于 codeception/base,codeception/base 依赖于 yiisoft/yii2-app-advanced

图3

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             框架服务控制台的用户
    cmc-console-user/sync      同步框架服务控制台的用户模型(Http)至框架服务控制台的用户模型(R
                               edis)

- config-column-user           栏目人员配置
    config-column-user/sync    同步框架服务控制台的用户模型(Http)至栏目人员配置模型(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/delete                 日志的删除

- 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                    选题任务
    plan-task/close            关闭选题任务

- 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 <command-name>

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、分别查看 codeception/base 的两个版本的 composer.json,Yii Framework 从 2.0.15.1 版本升级到 2.0.31,进而导致 codeception/base 从版本 2.5.2 升级到 2.5.6,而 codeception/base 的版本 2.5.6 已经放弃依赖 guzzlehttp/guzzle。观察可发现,codeception/base 的依赖类型为:require-dev,因此,其仅能够用于开发阶段,而不能够用于生产阶段。

    "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"
    },

 

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/181476.html

(0)
上一篇 2021年11月1日
下一篇 2021年11月1日

相关推荐

发表回复

登录后才能评论