如何在将 PHP 升级到 8.0 后修复 laravel/ui 升级 Laravel 的错误

How to fix laravel/ui error to upgrade Laravel after upgrading PHP to 8.0

我正在尝试在 PHP 升级到 8.0 后使用 brew 在 macOS 上升级 Laravel,但出现以下错误。我该如何解决?

$ composer update                                                                                                                  ✔ │ 59% hdd │ 5.43G RAM │ 14:05:07 │ ⇣0.18 KiB/s ⇡1.51 KiB/s 192.168.1.69 IP │ 213.163.173.1 IP 
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install laravel/framework v8.12.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.12.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.12.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.12.3 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.13.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.14.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.15.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.16.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.16.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.17.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.17.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.17.2 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.18.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v8.18.1 (conflict analysis result)
    - laravel/ui[v2.1.0, ..., v2.4.1] require php ^7.2.5 -> your php version (8.0.0) does not satisfy that requirement.
    - illuminate/support[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.0.0) does not satisfy that requirement.
    - laravel/framework[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.0.0) does not satisfy that requirement.
    - laravel/ui[v2.5.0, ..., 2.x-dev] require illuminate/support ^7.0 -> satisfiable by illuminate/support[v7.0.0, ..., 7.x-dev].
    - Only one of these can be installed: illuminate/support[dev-master, v5.5.0, ..., 5.8.x-dev, v6.0.0, ..., 6.x-dev, v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev], laravel/framework[v8.0.0, ..., 8.x-dev]. laravel/framework replaces illuminate/support and thus cannot coexist with it.
    - Root composer.json requires laravel/framework ^8.0 -> satisfiable by laravel/framework[v8.0.0, ..., 8.x-dev].
    - Root composer.json requires laravel/ui ^2.1 -> satisfiable by laravel/ui[v2.1.0, ..., 2.x-dev].

=== 编辑 2020-12-10 ===

composer.json:

{
    "name": "laravel/laravel",
    "type": "project",
    "description": "The Laravel Framework.",
    "keywords": [
        "framework",
        "laravel"
    ],
    "license": "MIT",
    "require": {
        "php": "^8.0",
        "fideloper/proxy": "^4.2",
        "fruitcake/laravel-cors": "^2.0",
        "guzzlehttp/guzzle": "^7.0.1",
        "laravel/framework": "^8.0",
        "laravel/passport": "^10.0.1",
        "laravel/tinker": "^2.0",
        "laravel/ui": "^2.1"
    },
    "require-dev": {
        "facade/ignition": "^2.3.6",
        "fakerphp/faker": "^1.9.1",
        "mockery/mockery": "^1.3.1",
        "nunomaduro/collision": "^5.0",
        "phpunit/phpunit": "^9.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        }
    },
    "autoload": {
        "psr-4": {
            "App\": "app/",
            "Database\Factories\": "database/factories/",
            "Database\Seeders\": "database/seeders/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "scripts": {
        "post-autoload-dump": [
            "Illuminate\Foundation\ComposerScripts::postAutoloadDump",
            "@php artisan package:discover --ansi"
        ],
        "post-root-package-install": [
            "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "@php artisan key:generate --ansi"
        ]
    }
}

低于

如这些多行错误中所写:您使用的是过时的软件包,它们与 PHP 8 不兼容,彼此也不兼容。

您需要 v2 中的 laravel/ui,它只支持 Laravel v7,以及 laravel/framework,它是 Laravel v8 的核心。将 laravel/ui 更新到 v3,或将 Laravel 降级到 v7。从我的角度来看,这个问题与 PHP8 无关 - 你之前没有遇到任何问题真是个奇迹