简体   繁体   English

Laravel Valet - 锁定文件中已弃用的依赖项

[英]Laravel Valet - deprecated dependencies in lock file

On running composer global require laravel/valet , illuminate/contracts and illuminate/container are locked to v5.4.36:在运行composer global require laravel/valet时,illuminate/contracts 和 illuminate/container 被锁定到 v5.4.36:

  - Locking illuminate/container (v5.4.36)
  - Locking illuminate/contracts (v5.4.36)

Running any valet command returns a long list of deprecated methods similar to the following:运行任何valet命令都会返回一长串已弃用的方法,类似于以下内容:

Deprecated: Return type of Illuminate\Container\Container::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /Users/lluismather/.composer/vendor/illuminate/container/Container.php on line 1159
Deprecated: Method ReflectionParameter::getClass() is deprecated in /Users/lluismather/.composer/vendor/illuminate/container/Container.php on line 788

If I try to upgrade these I get the following error:如果我尝试升级这些,我会收到以下错误:

Problem 1
    - Root composer.json requires illuminate/contracts 8.77.1 -> satisfiable by illuminate/contracts[v8.77.1].
    - illuminate/contracts v8.77.1 requires psr/container ^1.0 -> found psr/container[1.0.0, 1.1.0, 1.1.1, 1.1.2] but the package is fixed to 2.0.2 (lock file version) by a partial update and that version does not match. Make sure you list it as an argument for the update command.
  Problem 2
    - illuminate/container v5.4.36 requires illuminate/contracts 5.4.* -> found illuminate/contracts[v5.4.0, ..., v5.4.36] but it conflicts with your root composer.json require (8.77.1).
    - laravel/valet v2.18.1 requires illuminate/container ~5.1|^6.0|^7.0|^8.0 -> satisfiable by illuminate/container[v5.4.36].
    - laravel/valet is locked to version v2.18.1 and an update of this package was not requested.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

It seems to me as though valet is locking deprecated versions of these packages, resulting in the warnings and errors I'm getting.在我看来,好像 valet 正在锁定这些软件包的弃用版本,导致我收到警告和错误。 Any thoughts or insights in how to upgrade illuminate/contracts and illuminate/container to stop the deprecation notices and make valet play ball with my current setup would be greatly appreciated.任何关于如何升级illuminate/contractsilluminate/container以停止弃用通知并让代客使用我当前的设置玩球的想法或见解将不胜感激。

Versions: php 8.1.1 composer 2.1.14 laravel 8 valet 2.18.1版本:php 8.1.1 作曲家 2.1.14 laravel 8 代客 2.18.1

I have the same problem.我也有同样的问题。 It seems that when a package defines its own dependencies and lists multiple major version options, the lowest one is used by default (and locked) which causes Valet to use illuminate/container:^5.4 which drags along its own dependencies.似乎当 package 定义其自己的依赖项并列出多个主要版本选项时,默认使用(并锁定)最低的一个,这导致 Valet 使用illuminate/container:^5.4 ,这会拖累它自己的依赖项。

The solution for me was to add v8 to the global composer.json, eg:我的解决方案是将 v8 添加到全局 composer.json,例如:

{
    "require": {
        "illuminate/container": "^8.0",
        "laravel/installer": "^4.0",
        "laravel/valet": "^2.0",
    }
}

I removed the composer.lock file and the vendor folder and ran another composer global update which fixed the problem.我删除了composer.lock文件和 vendor 文件夹,并运行了另一个composer global update来解决这个问题。

What is strange though, is that it only appeared recently even though I have been using PHP 8.x for quite some time.奇怪的是,尽管我使用 PHP 8.x 已有一段时间了,但它最近才出现。

I was having the same issue after upgrading to PHP 8.1 using brew and trying to use php 7.4 for a older project.在使用 brew 升级到 PHP 8.1 并尝试将 php 7.4 用于旧项目后,我遇到了同样的问题。

The solution given by mniess seems to work but it's strange that this started happening with any major changes. mniess 给出的解决方案似乎有效,但奇怪的是,随着任何重大变化开始发生这种情况。

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

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