简体   繁体   English

如何降级我的依赖版本的依赖[作曲家]

[英]how to downgrade dependency of my dependencies version [composer]

I did composer update recently.我最近做了composer update But new version of my dependencies what I got I completely don't like.但是我得到的新版本的依赖项我完全不喜欢。 I would say that I don't like dependency of my dependencies, it's more precise.我会说我不喜欢依赖我的依​​赖,它更精确。 Is there any way to roll back, except fetching from git history composer.lock ?除了从 git history composer.lock获取之外,有没有办法回滚?

I've had a similar problem with laravel/passport =7.5.1 , that depends on league/oauth2-server ^7.0 , that requires lcobucci/jwt ^3.2.2 .我对laravel/passport =7.5.1也有类似的问题,这取决于 League league/oauth2-server ^7.0 ,这需要lcobucci/jwt ^3.2.2 And at the time, lcobucci/jwt was updated to latest 3.4 version.而当时, lcobucci/jwt已经更新到最新的3.4版本。 But this sudden update introduces the bug, so everyone has to downgrade it to 3.3.* .但是这个突然的更新引入了这个bug,所以大家不得不降级到3.3.*

You can override the version of nested dependency needed or apply another version number constraint by simply putting it in require section of your top-level composer.json :您可以覆盖所需的嵌套依赖项的版本或应用另一个版本号约束,只需将其放入顶级composer.jsonrequire部分:

    "require": {
        ...
        "lcobucci/jwt": "3.3.*"
    }

Then don't forget to run composer update lcobucci/jwt , so it installs the right version of nested dependency and updates the record in composer.lock .然后不要忘记运行composer update lcobucci/jwt ,它会安装正确版本的嵌套依赖并更新composer.lock中的记录。

There is no direct way of downgrading a dependency of a dependency;没有直接的方法来降级依赖项的依赖项; it takes some work:这需要一些工作:

  1. Require the package in the desired version需要所需版本的软件包

    composer require aws/aws-sdk-php=3.158.17

    The dependency will be downgraded.依赖项将被降级。 It also gets added to composer.json which we don't want, because our application does not depend on it.它也被添加到我们不想要的 composer.json 中,因为我们的应用程序不依赖它。

  2. Simply removing the dependency with "composer remove" will upgrade the package to the lastest version which we don't want.只需使用“composer remove”删除依赖项即可将包升级到我们不想要的最新版本。

    So instead, manually remove the require line from composer.json and run composer update nothing to update the hash in composer.lock .因此,请手动从composer.json中删除 require 行并运行composer update nothing来更新composer.lock中的哈希。

Today it is better to put the version to 3.4 and also install mbstring on your system with the command:今天最好将版本设置为 3.4,并使用以下命令在您的系统上安装 mbstring:

sudo apt-get install php-mbstring

If you are under ubuntu and finally do a composer update lcobucci / jwt just like you say.如果你在 ubuntu 下,最后像你说的那样做一个composer update lcobucci / jwt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM