1

在运行composer global require laravel/valet时,照明/合同和照明/容器被锁定到 v5.4.36:

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

运行任何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

如果我尝试升级这些,我会收到以下错误:

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.

在我看来,好像代客锁定了这些软件包的弃用版本,导致我收到警告和错误。对于如何升级illuminate/contractsilluminate/container停止弃用通知以及使用我当前的设置进行代客打球的任何想法或见解将不胜感激。

版本:php 8.1.1 composer 2.1.14 laravel 8 valet 2.18.1

4

1 回答 1

2

我也有同样的问题。似乎当一个包定义了自己的依赖项并列出了多个主要版本选项时,默认情况下使用最低的一个(并锁定),这导致 Valet 使用illuminate/container:^5.4它拖着它自己的依赖项。

我的解决方案是将 v8 添加到全局 composer.json,例如:

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

我删除了composer.lock文件和供应商文件夹并运行了另一个composer global update解决了问题的文件夹。

奇怪的是,尽管我使用 PHP 8.x 已经有一段时间了,但它最近才出现。

于 2022-01-07T16:58:28.833 回答