Laravel 8 未安装图像干预包

Naz*_*que 2 image intervention

您的要求无法解析为一组可安装的软件包。

问题1

- intervention/image[2.5.0, ..., 2.5.1] require guzzlehttp/psr7 ~1.1 -> found guzzlehttp/psr7[1.1.0, ..., 1.x-dev] but the package is fixed to 2.0.0 (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.
- Root composer.json requires intervention/image ^2.5 -> satisfiable by intervention/image[2.5.0, 2.5.1].
Run Code Online (Sandbox Code Playgroud)

使用选项 --with-all-dependencies (-W) 允许升级、降级和删除当前锁定到特定版本的软件包。

作曲家.json

{
"name": "laravel/laravel",
"type": "project",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"require": {
    "php": "^7.3|^8.0",
    "fideloper/proxy": "^4.4",
    "fruitcake/laravel-cors": "^2.0",
    "guzzlehttp/guzzle": "^7.3",
    "laravel/framework": "^8.40",
    "laravel/tinker": "^2.5",
    "laravel/ui": "^3.3"
},
"require-dev": {
    "facade/ignition": "^2.5",
    "fakerphp/faker": "^1.9.1",
    "laravel/sail": "^1.0.1",
    "mockery/mockery": "^1.4.2",
    "nunomaduro/collision": "^5.0",
    "phpunit/phpunit": "^9.3.3"
},
"autoload": {
    "psr-4": {
        "App\\": "app/",
        "Database\\Factories\\": "database/factories/",
        "Database\\Seeders\\": "database/seeders/"
    }
},
"autoload-dev": {
    "psr-4": {
        "Tests\\": "tests/"
    }
},
"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"
    ]
},
"extra": {
    "laravel": {
        "dont-discover": []
    }
},
"config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable": true
}  
Run Code Online (Sandbox Code Playgroud)

Kua*_*iew 5

解决方案

  1. 转到composer.lock文件并搜索guzzlehttp/psr7,你会发现类似这样的内容
    "name": "guzzlehttp/psr7",
    "version": "2.0.0",
Run Code Online (Sandbox Code Playgroud)
  1. 将“版本”更改为“1.7.0”

  2. 再次运行命令composer require intervention/image。如果您看到一条消息,指出“降级 psr7 (2.0.0 => 1.7.0)”(我正在使用 powershell 顺便说一句),这意味着一切运行正常。

尝试解释

错误消息指出,为了安装intervention/image,需要guzzlehttp/psr7[1.1.0, ..., 1.x-dev]。这意味着它需要版本 1.x 的 psr7 ,但是,laravel 8 中的 psr7 是版本 2.0.0 并且不兼容。在此处了解有关语义版本控制的更多信息

你可以在你的composer.lock文件中检查这一点,通过搜索“guzzlehttp/psr7”然后你会看到类似这样的东西

    "name": "guzzlehttp/psr7",
    "version": "2.0.0",
Run Code Online (Sandbox Code Playgroud)

因此,您需要将其降级到 1.x 版本。但是1.x版本也有很多,我选择的是1.7.0,因为在guzzlehttp根包中,还有一些其他子包(我使用的术语可能不合适,请原谅我)要求psr7至少为1.7 .0,这就是我选择 1.7.0 的原因,到目前为止,干预/图像包对我来说效果很好。

我看到其他一些关于删除composer.lock文件的评论,它有效。但是我对删除composer.lock文件有些担心,因为它包含非常重要的信息......