我尝试通过 laravel 安装程序使用
laravel new <appname>
创建一个新的 laravel 应用程序。
这工作没有问题。当我尝试安装
spatie/medialibrary
时,我收到以下无法解释的错误:
$ composer require "spatie/laravel-medialibrary:^9.0.0"
./composer.json has been updated
Running composer update spatie/laravel-medialibrary
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- spatie/laravel-medialibrary[9.0.0, ..., 9.6.4] require spatie/image ^1.4.0 -> satisfiable by spatie/image[1.4.0, ..., v1.x-dev].
- spatie/image[1.10.0, ..., v1.x-dev] require league/glide ^1.6 -> satisfiable by league/glide[1.6.0, 1.6.1, 1.7.0, 1.x-dev].
- spatie/image[1.7.5, ..., 1.9.0] require league/glide ^1.4 -> satisfiable by league/glide[1.4.0, ..., 1.x-dev].
- league/glide[1.4.0, ..., 1.x-dev] require intervention/image ^2.4 -> satisfiable by intervention/image[2.4.0, ..., 2.5.1].
- intervention/image 2.4.x-dev is an alias of intervention/image dev-master and thus requires it to be installed too.
- spatie/image 1.10.3 requires league/glide ^2.0 -> satisfiable by league/glide[2.0.0, 2.0.x-dev].
- intervention/image[dev-master, 2.4.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.
- league/glide 2.0.x-dev requires 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.
- league/glide 2.0.0 requires league/flysystem ^2.0 -> found league/flysystem[2.0.0-alpha.1, ..., 2.x-dev] but the package is fixed to 1.1.4 (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.
- spatie/image 1.4.0 requires symfony/process ^3.0 -> found symfony/process[v3.0.0-BETA1, ..., 3.4.x-dev] but the package is fixed to v5.3.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.
- spatie/image[1.4.1, ..., 1.7.4] require symfony/process ^3.0|^4.0 -> found symfony/process[v3.0.0-BETA1, ..., 3.4.x-dev, v4.0.0-BETA1, ..., 4.4.x-dev] but the package is fixed to v5.3.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.
- Root composer.json requires spatie/laravel-medialibrary ^9.0.0 -> satisfiable by spatie/laravel-medialibrary[9.0.0, ..., 9.6.4].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
即使我尝试允许 Composer 自动升级/降级不匹配的包,我仍然会遇到类似的错误:
$ composer require "spatie/laravel-medialibrary:^9.0.0" -W
./composer.json has been updated
Running composer update spatie/laravel-medialibrary --with-all-dependencies
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires laravel/framework ^8.0, found laravel/framework[v8.0.0, ..., 8.x-dev] but these were not loaded, likely because it conflicts with another require.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
这也是我的
composer.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.0.1",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.5"
},
"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
}
作曲版本:
Composer version 2.1.3 2021-06-09 16:31:20
PHP版本:
$ php -v
PHP 7.4.9 (cli)
我不明白这里的问题是什么,laravel 安装的要求是通过应用程序的全新创建来满足的,medialibrary 包需要版本 7+ 的 laravel 框架。
我是否遗漏了一些告诉我出了什么问题的东西?
谢谢
您可以通过运行忽略平台要求
composer install --ignore-platform-reqs
或者用这个升级、降级
composer install --with-all-dependencies
并删除composer.lock文件(安装前)
sudo rm composer.lock
在我的例子中,当要运行测试时要安装 spatie/image 3.3.3 或 3.3.2 时要安装 spatie/medialibrary 11
错误是:
文件名太长
我的问题解决了:
git config --system core.longpaths true