Search code examples
phplaravellaravel-valetilluminate-containervalet

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:

  - 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:

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. 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.

Versions: php 8.1.1 composer 2.1.14 laravel 8 valet 2.18.1


Solution

  • 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.

    The solution for me was to add v8 to the global composer.json, e.g.:

    {
        "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.

    What is strange though, is that it only appeared recently even though I have been using PHP 8.x for quite some time.