英文:
upgrading to laravel 10 and can not seem to find the correct aws-sdk
问题
我正在升级从laravel 8到10,以及到php 8.2。
我清理了我的composer.json并痛苦地通过"composer require"添加了每个包,以便我可以获得所有正确的版本。
我在使aws S3正常工作方面遇到了最后的障碍。我似乎找不到一个可以与laravel 10的依赖关系一起工作的包。
有人能够让它与v10和S3一起工作吗?
我尝试过
composer require league/flysystem-aws-s3-v3 ~1.0
问题 1
- league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.13]需要league/flysystem ~1.0 -> 找到league/flysystem[1.0.0, ..., 1.1.10],但它与您的根composer.json要求 (^3.15.1) 冲突。
- league/flysystem-aws-s3-v3[1.0.15, ..., 1.0.30]需要league/flysystem ^1.0.40 -> 找到league/flysystem[1.0.40, ..., 1.1.10],但它与您的根composer.json要求 (^3.15.1) 冲突。
- 根composer.json要求league/flysystem-aws-s3-v3 ~1.0 -> 可满足于league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.30]。
我也尝试过
composer require league/flysystem-aws-s3-v3 ~3.0
问题 1
- league/flysystem-aws-s3-v3[3.12.1, ..., 3.15.0]需要aws/aws-sdk-php ^3.220.0 -> 可满足于aws/aws-sdk-php[3.220.0, ..., 3.275.4]。
- league/flysystem-aws-s3-v3[3.0.0, ..., 3.10.3]需要aws/aws-sdk-php ^3.132.4 -> 可满足于aws/aws-sdk-php[3.132.4, ..., 3.275.4]。
- aws/aws-sdk-php[3.132.4, ..., 3.173.19]需要guzzlehttp/psr7 ^1.4.1 -> 找到guzzlehttp/psr7[1.4.1, ..., 1.9.1],但它与您的根composer.json要求 (^2.5.0) 冲突。
- aws/aws-sdk-php[3.173.20, ..., 3.198.8]需要guzzlehttp/psr7 ^1.7.0 -> 找到guzzlehttp/psr7[1.7.0, ..., 1.9.1],但它与您的根composer.json要求 (^2.5.0) 冲突。
- aws/aws-sdk-php[3.199.0, ..., 3.275.4]需要guzzlehttp/promises ^1.4.0 -> 找到guzzlehttp/promises[1.4.0, ..., 1.5.3],但它与您的根composer.json要求 (^2.0.0) 冲突。
- 根composer.json要求league/flysystem-aws-s3-v3 ~3.0 -> 可满足于league/flysystem-aws-s3-v3[3.0.0, ..., 3.15.0]。
最后我尝试了
composer require league/flysystem-aws-s3-v3
问题 1
- league/flysystem-aws-s3-v3[3.12.1, ..., 3.15.0]需要aws/aws-sdk-php ^3.220.0 -> 可满足于aws/aws-sdk-php[3.220.0, ..., 3.275.4]。
- league/flysystem-aws-s3-v3[3.0.0, ..., 3.10.3]需要aws/aws-sdk-php ^3.132.4 -> 可满足于aws/aws-sdk-php[3.132.4, ..., 3.275.4]。
- league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.13]需要league/flysystem ~1.0 -> 找到league/flysystem[1.0.0, ..., 1.1.10],但它与您的根composer.json要求 (^3.15.1) 冲突。
- league/flysystem-aws-s3-v3[1.0.15, ..., 1.0.30]需要league/flysystem ^1.0.40 -> 找到league/flysystem[1.0.40, ..., 1.1.10],但它与您的根composer.json要求 (^3.15.1) 冲突。
- league/flysystem-aws-s3-v3[2.0.0, ..., 2.5.0]需要league/flysystem ^2.0.0 -> 找到league/flysystem[2.0.0, ..., 2.5.0],但它与您的根composer.json要求 (^3.15.1) 冲突。
- aws/aws-sdk-php[3.131.0, ..., 3.173.19]需要guzzlehttp/psr7 ^1.4.1 -> 找到guzzlehttp/psr7[1.4.1, ..., 1.9.1],但它与您的根composer.json要求 (^2.5.0) 冲突。
- aws/aws-sdk-php[3.173.20, ..., 3.198.8]需要guzzlehttp/psr7 ^1.7.0 -> 找到guzzlehttp/psr7[1.7.0, ..., 1.9.1],但它与您的根composer.json要求 (^2.5.0) 冲突。
- aws/aws-sdk-php[3.199.0, ..., 3.275.4]需要guzzlehttp/promises ^1.4.0 -> 找到guzzlehttp/promises[1.4.0, ..., 1.5.3],但
英文:
I am upgrading from laravel 8 to 10 and to php 8.2
I cleared out my composer.json and painfully added each package via "composer require" so i could get all the correct versions.
My last stumbling block in getting aws S3 to work. I can not seem to find a package that will work with laravel 10 dependancies.
Has any one got it to work with v10 and s3?
The package i used with laravel 8 sociallydev/spaces-api has some old dependancies that can not work with v10.
I tried
composer require league/flysystem-aws-s3-v3 ~1.0
Problem 1
- league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.13] require league/flysystem ~1.0 -> found league/flysystem[1.0.0, ..., 1.1.10] but it conflicts with your root composer.json require (^3.15.1).
- league/flysystem-aws-s3-v3[1.0.15, ..., 1.0.30] require league/flysystem ^1.0.40 -> found league/flysystem[1.0.40, ..., 1.1.10] but it conflicts with your root composer.json require (^3.15.1).
- Root composer.json requires league/flysystem-aws-s3-v3 ~1.0 -> satisfiable by league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.30].
i also tried
composer require league/flysystem-aws-s3-v3 ~3.0
Problem 1
- league/flysystem-aws-s3-v3[3.12.1, ..., 3.15.0] require aws/aws-sdk-php ^3.220.0 -> satisfiable by aws/aws-sdk-php[3.220.0, ..., 3.275.4].
- league/flysystem-aws-s3-v3[3.0.0, ..., 3.10.3] require aws/aws-sdk-php ^3.132.4 -> satisfiable by aws/aws-sdk-php[3.132.4, ..., 3.275.4].
- aws/aws-sdk-php[3.132.4, ..., 3.173.19] require guzzlehttp/psr7 ^1.4.1 -> found guzzlehttp/psr7[1.4.1, ..., 1.9.1] but it conflicts with your root composer.json require (^2.5.0).
- aws/aws-sdk-php[3.173.20, ..., 3.198.8] require guzzlehttp/psr7 ^1.7.0 -> found guzzlehttp/psr7[1.7.0, ..., 1.9.1] but it conflicts with your root composer.json require (^2.5.0).
- aws/aws-sdk-php[3.199.0, ..., 3.275.4] require guzzlehttp/promises ^1.4.0 -> found guzzlehttp/promises[1.4.0, ..., 1.5.3] but it conflicts with your root composer.json require (^2.0.0).
- Root composer.json requires league/flysystem-aws-s3-v3 ~3.0 -> satisfiable by league/flysystem-aws-s3-v3[3.0.0, ..., 3.15.0].
and finally
composer require league/flysystem-aws-s3-v3
Problem 1
- league/flysystem-aws-s3-v3[3.12.1, ..., 3.15.0] require aws/aws-sdk-php ^3.220.0 -> satisfiable by aws/aws-sdk-php[3.220.0, ..., 3.275.4].
- league/flysystem-aws-s3-v3[3.0.0, ..., 3.10.3] require aws/aws-sdk-php ^3.132.4 -> satisfiable by aws/aws-sdk-php[3.132.4, ..., 3.275.4].
- league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.13] require league/flysystem ~1.0 -> found league/flysystem[1.0.0, ..., 1.1.10] but it conflicts with your root composer.json require (^3.15.1).
- league/flysystem-aws-s3-v3[1.0.15, ..., 1.0.30] require league/flysystem ^1.0.40 -> found league/flysystem[1.0.40, ..., 1.1.10] but it conflicts with your root composer.json require (^3.15.1).
- league/flysystem-aws-s3-v3[2.0.0, ..., 2.5.0] require league/flysystem ^2.0.0 -> found league/flysystem[2.0.0, ..., 2.5.0] but it conflicts with your root composer.json require (^3.15.1).
- aws/aws-sdk-php[3.131.0, ..., 3.173.19] require guzzlehttp/psr7 ^1.4.1 -> found guzzlehttp/psr7[1.4.1, ..., 1.9.1] but it conflicts with your root composer.json require (^2.5.0).
- aws/aws-sdk-php[3.173.20, ..., 3.198.8] require guzzlehttp/psr7 ^1.7.0 -> found guzzlehttp/psr7[1.7.0, ..., 1.9.1] but it conflicts with your root composer.json require (^2.5.0).
- aws/aws-sdk-php[3.199.0, ..., 3.275.4] require guzzlehttp/promises ^1.4.0 -> found guzzlehttp/promises[1.4.0, ..., 1.5.3] but it conflicts with your root composer.json require (^2.0.0).
- Root composer.json requires league/flysystem-aws-s3-v3 * -> satisfiable by league/flysystem-aws-s3-v3[1.0.0, ..., 1.0.30, 2.0.0, ..., 2.5.0, 3.0.0, ..., 3.15.0].
here is my composer.json
{
"name": "laravel/laravel",
"type": "project",
"description": "The skeleton application for the Laravel framework.",
"keywords": ["laravel", "framework"],
"license": "MIT",
"require": {
"asm89/stack-cors": "*",
"brick/math": "*",
"dnoegel/php-xdg-base-dir": "*",
"doctrine/inflector": "^2.0",
"doctrine/instantiator": "^2.0",
"doctrine/lexer": "^3.0",
"dragonmantank/cron-expression": "^3.3",
"egulias/email-validator": "^4.0",
"elic-dev/laravel-site-protection": "^1.1",
"facade/ignition-contracts": "^1.0",
"guzzlehttp/guzzle": "^7.7.0",
"guzzlehttp/promises": "^2.0.0",
"guzzlehttp/psr7": "^2.5.0",
"hamcrest/hamcrest-php": "^2.0",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.2",
"laravelcollective/html": "^6.4",
"league/commonmark": "^2.4",
"league/flysystem": "^3.15.1",
"monolog/monolog": "^3.4",
"myclabs/deep-copy": "^1.11",
"nesbot/carbon": "^2.68",
"nikic/php-parser": "^4.16",
"opis/closure": "^3.6",
"phar-io/manifest": "^2.0",
"phar-io/version": "^3.2",
"phpdocumentor/reflection-docblock": "^5.3",
"phpdocumentor/type-resolver": "^1.7",
"phpoption/phpoption": "^1.9",
"phpspec/prophecy": "^1.1",
"psr/container": "^2.0",
"psr/event-dispatcher": "^1.0",
"psr/http-message": "^1.0.1",
"psr/log": "^3.0",
"psr/simple-cache": "^3.0",
"psy/psysh": "^0.11.18",
"ralouphie/getallheaders": "^3.0",
"ramsey/collection": "^2.0",
"ramsey/uuid": "^4.7",
"sebastian/code-unit-reverse-lookup": "^3.0",
"sebastian/comparator": "^5.0",
"sebastian/diff": "^5.0",
"sebastian/environment": "^6.0",
"sebastian/exporter": "^5.0",
"sebastian/global-state": "^6.0",
"sebastian/object-enumerator": "^5.0",
"sebastian/object-reflector": "^3.0",
"sebastian/recursion-context": "^5.0",
"sebastian/resource-operations": "^3.0",
"sebastian/type": "^4.0",
"sebastian/version": "^4.0",
"spatie/laravel-permission": "^5.10",
"spatie/laravel-sluggable": "*",
"swiftmailer/swiftmailer": "^5.4",
"symfony/css-selector": "^6.3",
"symfony/deprecation-contracts": "^3.3",
"symfony/error-handler": "^6.3",
"symfony/event-dispatcher": "^6.3",
"symfony/event-dispatcher-contracts": "^3.3",
"symfony/finder": "^6.3",
"symfony/http-foundation": "^6.3",
"symfony/http-kernel": "^6.3",
"symfony/mime": "^6.3",
"symfony/polyfill-ctype": "^1.27",
"symfony/polyfill-iconv": "^1.27",
"symfony/polyfill-intl-grapheme": "^1.27",
"symfony/polyfill-intl-idn": "^1.27",
"symfony/polyfill-intl-normalizer": "^1.27",
"symfony/polyfill-mbstring": "^1.27",
"symfony/polyfill-php72": "^1.27",
"symfony/polyfill-php73": "^1.27",
"symfony/polyfill-php80": "^1.27",
"symfony/process": "^6.3",
"symfony/routing": "^6.3",
"symfony/service-contracts": "^3.3",
"symfony/string": "^6.3",
"symfony/translation": "^6.3",
"symfony/translation-contracts": "^3.3",
"symfony/var-dumper": "^6.3",
"theseer/tokenizer": "^1.2",
"tijsverkoyen/css-to-inline-styles": "^2.2",
"vemcogroup/laravel-sparkpost-driver": "^5.0.5",
"vlucas/phpdotenv": "^5.5",
"voku/portable-ascii": "^2.0",
"webmozart/assert": "^1.11"
},
"require-dev": {
"fakerphp/faker": "^1.9.1",
"laravel/pint": "^1.0",
"laravel/sail": "^1.18",
"mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^7.7",
"phpdocumentor/reflection-common": "^2.2",
"phpunit/phpunit": "^10.1",
"spatie/laravel-ignition": "^2.0"
},
"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-update-cmd": [
"@php artisan vendor:publish --tag=laravel-assets --ansi --force"
],
"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,
"allow-plugins": {
"pestphp/pest-plugin": true,
"php-http/discovery": true
}
},
"minimum-stability": "stable",
"prefer-stable": true
}
here is the original version of the required list
"require": {
"asm89/stack-cors": "^1.3.0",
"brick/math": "^0.8.15",
"dnoegel/php-xdg-base-dir": "^0.1.1",
"doctrine/inflector": "^2.0.3",
"doctrine/instantiator": "^1.3.1",
"doctrine/lexer": "^1.2.1",
"dragonmantank/cron-expression": "^2.3.0",
"egulias/email-validator": "^2.1.18",
"elic-dev/laravel-site-protection": "^1.1",
"facade/flare-client-php": "^1.3.2",
"facade/ignition": "^2.0.7",
"facade/ignition-contracts": "^1.0.0",
"fideloper/proxy": "^4.4.0",
"fruitcake/laravel-cors": "^1.0.6",
"fzaninotto/faker": "^1.9.1",
"guzzlehttp/guzzle": "^6.5.5",
"guzzlehttp/promises": "^1.3.1",
"guzzlehttp/psr7": "^1.6.1",
"hamcrest/hamcrest-php": "^2.0.0",
"laravel/framework": "^7.19.0",
"laravel/socialite": "^5.2",
"laravel/tinker": "^2.4.0",
"laravel/ui": "^2.1.0",
"laravelcollective/html": "^6.1.2",
"league/commonmark": "^1.5.1",
"league/flysystem": "^1.0.69",
"monolog/monolog": "^2.1.0",
"myclabs/deep-copy": "^1.10.1",
"nesbot/carbon": "^2.36.1",
"nikic/php-parser": "^4.6.0",
"nunomaduro/collision": "^3.0",
"opis/closure": "^3.5.5",
"paypal/rest-api-sdk-php": "1.14",
"phar-io/manifest": "^1.0.3",
"phar-io/version": "^2.0.1",
"phpdocumentor/reflection-common": "^2.2.0",
"phpdocumentor/reflection-docblock": "^5.1.0",
"phpdocumentor/type-resolver": "^1.3.0",
"phpoption/phpoption": "^1.7.4",
"phpspec/prophecy": "^1.10.3",
"psr/container": "^1.0.0",
"psr/event-dispatcher": "^1.0.0",
"psr/http-message": "^1.0.1",
"psr/log": "^1.1.3",
"psr/simple-cache": "^1.0.1",
"psy/psysh": "^0.10.4",
"ralouphie/getallheaders": "^3.0.3",
"ramsey/collection": "^1.0.1",
"ramsey/uuid": "^4.0.1",
"sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/comparator": "^3.0.2",
"sebastian/diff": "^3.0.2",
"sebastian/environment": "^4.2.3",
"sebastian/exporter": "^3.1.2",
"sebastian/global-state": "^2.0.0",
"sebastian/object-enumerator": "^3.0.3",
"sebastian/object-reflector": "^1.1.1",
"sebastian/recursion-context": "^3.0.0",
"sebastian/resource-operations": "^2.0.1",
"sebastian/type": "^1.1.3",
"sebastian/version": "^2.0.1",
"sociallydev/spaces-api": "v2",
"spatie/laravel-permission": "^3.13.0",
"spatie/laravel-sluggable": "^2.2",
"square/square": "12.0.0.20210616",
"swiftmailer/swiftmailer": "^6.2.3",
"symfony/css-selector": "^5.1.2",
"symfony/deprecation-contracts": "^2.1.3",
"symfony/error-handler": "^5.1.2",
"symfony/event-dispatcher": "^5.1.2",
"symfony/event-dispatcher-contracts": "^2.1.3",
"symfony/finder": "^5.1.2",
"symfony/http-foundation": "^5.1.2",
"symfony/http-kernel": "^5.1.2",
"symfony/mime": "^5.1.2",
"symfony/polyfill-ctype": "^1.17.1",
"symfony/polyfill-iconv": "^1.17.1",
"symfony/polyfill-intl-grapheme": "^1.17.1",
"symfony/polyfill-intl-idn": "^1.17.1",
"symfony/polyfill-intl-normalizer": "^1.17.1",
"symfony/polyfill-mbstring": "^1.17.1",
"symfony/polyfill-php72": "^1.17.0",
"symfony/polyfill-php73": "^1.17.1",
"symfony/polyfill-php80": "^1.17.1",
"symfony/process": "^5.1.2",
"symfony/routing": "^5.1.2",
"symfony/service-contracts": "^2.1.3",
"symfony/string": "^5.1.2",
"symfony/translation": "^5.1.2",
"symfony/translation-contracts": "^2.1.3",
"symfony/var-dumper": "^5.1.2",
"theseer/tokenizer": "^1.1.3",
"tijsverkoyen/css-to-inline-styles": "^2.2.2",
"vemcogroup/laravel-sparkpost-driver": "4.x",
"vlucas/phpdotenv": "^4.1.7",
"voku/portable-ascii": "^1.5.2",
"webmozart/assert": "^1.9.0"
},
答案1
得分: 1
这并不完全是对你问题的回答,但这是一种让你清理composer.json
文件的方法(而且它太冗长了,无法在评论中很好地格式化)。
正如评论中所述,许多包会作为依赖项安装,无需明确声明。有一种方法可以确切地知道哪些包可以安全地移除。
基本的 composer.json
这是在使用以下命令创建的新 Laravel 7 安装中 require
部分的样子:
"name": "laravel/laravel",
"require": {
"php": "^7.2.5|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
额外的包
现在,我将添加两个我知道已经被要求的包,只是为了举例:
"name": "laravel/laravel",
"require": {
"php": "^7.2.5|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5",
"symfony/polyfill-php72": "^1.27", <---
"symfony/polyfill-php80": "^1.27" <---
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
谁依赖于 X 包?
现在,如何知道(没有先验知识的情况下)symfony/polyfill-php80
和 symfony/polyfill-php72
不应该在这里?一个好方法是使用命令 composer why <package>
。
这个命令将告诉你为什么安装了一个包。例如,对于 laravel/tinker
,这是结果:
$ composer why laravel/tinker
laravel/laravel - requires laravel/tinker (^2.5)
这告诉你 laravel/laravel
(在你的 composer.json
的 name
键中声明的默认项目名称)需要 laravel/tinker
。没有别的。
现在看看 symfony/polyfill-php72
和 symfony/polyfill-php80
的结果:
$ composer why symfony/polyfill-php72
laravel/laravel - requires symfony/polyfill-php72 (^1.27)
symfony/polyfill-intl-idn v1.27.0 requires symfony/polyfill-php72 (^1.10)
这表示除了在 composer.json
的 require
中声明之外,你的供应商目录中还安装了其他包,也需要它,这意味着你可以安全地从 composer.json
中删除它。
$ composer why symfony/polyfill-php80
laravel/laravel - requires symfony/polyfill-php80 (^1.27)
nesbot/carbon 2.68.1 requires symfony/polyfill-php80 (^1.16)
symfony/console v5.4.24 requires symfony/polyfill-php80 (^1.16)
...
这表示除了在 composer.json
的 require
中声明之外,你的供应商目录中安装的所有其他包也需要它,这意味着你可以安全地从 composer.json
中删除它。
删除这些包
有两种选项:
- 手动从
composer.json
文件中删除该行,然后运行composer update
(将从修改后的composer.json
重新生成composer.lock
文件) - 运行
composer remove <package>
这是我尝试清理我的 composer.json
文件的输出:
$ composer remove symfony/polyfill-php80
./composer.json has been updated
Running composer update symfony/polyfill-php80
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
74 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
Removal failed, symfony/polyfill-php80 is still present, it may be required by another package. See `composer why symfony/polyfill-php80`.
这里重要的是:
./composer.json has been updated
(它从你的require
数组中删除了依赖项)Nothing to modify in lock file
(这不会更改你的依赖关系)Removal failed, symfony/polyfill-php80 is still present, it may be required by another package. See composer why symfony/polyfill-php80.
(这正是我所说的:该依赖项已经被其他东西要求,所以它出现在你的 composer.json 中只会增加无谓的复杂性)。
... 基本上,你需要花很多时间来清理你的 composer.json 文件中的大多数包。
此外,每当你不确定 composer 命令会执行什么操作时,你可以附加 `--dry
英文:
This is not quite the answer to your question but it is a way for you to clean up your composer.json
file (and it's too verbose to really put in a comment nicely formatted).
As the comments state, a lot of packages get installed as dependencies without needing to be explicitly declared. There is a way for you to know exactly which packages you can safely remove.
Base composer.json
This is what the require
segments look on a fresh Laravel 7 installation created with the command
composer create-project --prefer-dist laravel/laravel:^7.0 blog
"name": "laravel/laravel",
"require": {
"php": "^7.2.5|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5"
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
Extra baggage
Now, I'll add two packages that I know are already required, just to make an example
"name": "laravel/laravel",
"require": {
"php": "^7.2.5|^8.0",
"fideloper/proxy": "^4.4",
"fruitcake/laravel-cors": "^2.0",
"guzzlehttp/guzzle": "^6.3.1|^7.0.1",
"laravel/framework": "^7.29",
"laravel/tinker": "^2.5",
"symfony/polyfill-php72": "^1.27", <---
"symfony/polyfill-php80": "^1.27" <---
},
"require-dev": {
"facade/ignition": "^2.0",
"fakerphp/faker": "^1.9.1",
"mockery/mockery": "^1.3.1",
"nunomaduro/collision": "^4.3",
"phpunit/phpunit": "^8.5.8|^9.3.3"
},
What depends on X package?
Now how do you know (without prior knowledge) that symfony/polifill-php80
and symfony/polifill-php72
should not be there? A good way is using the command composer why <package>
.
This command will tell why a package is installed. For example, for laravel/tinker
this is the result:
$ composer why laravel/tinker
laravel/laravel - requires laravel/tinker (^2.5)
This tells you that laravel/laravel
(the default name for your project (as stated in the name
key of your composer.json
is requiring laravel/tinker
. Nothing else.
Now look at the result for symfony/polyfill-php72
and symfony/polyfill-php80
$ composer why symfony/polyfill-php72
laravel/laravel - requires symfony/polyfill-php72 (^1.27)
symfony/polyfill-intl-idn v1.27.0 requires symfony/polyfill-php72 (^1.10)
this says that aside from it being in the composer.json
's require, another package installed in your vendor directory are also requiring it, meaning you can safely remove it from the composer.json
$ composer why symfony/polyfill-php80
laravel/laravel - requires symfony/polyfill-php80 (^1.27)
nesbot/carbon 2.68.1 requires symfony/polyfill-php80 (^1.16)
symfony/console v5.4.24 requires symfony/polyfill-php80 (^1.16)
symfony/finder v5.4.21 requires symfony/polyfill-php80 (^1.16)
symfony/http-foundation v5.4.25 requires symfony/polyfill-php80 (^1.16)
symfony/http-kernel v5.4.25 requires symfony/polyfill-php80 (^1.16)
symfony/mime v5.4.23 requires symfony/polyfill-php80 (^1.16)
symfony/process v5.4.24 requires symfony/polyfill-php80 (^1.16)
symfony/routing v5.4.25 requires symfony/polyfill-php80 (^1.16)
symfony/var-dumper v5.4.25 requires symfony/polyfill-php80 (^1.16)
this says that aside from it being in the composer.json
's require, all these other packages installed in your vendor directory are also requiring it, meaning you can safely remove it from the composer.json
Removing those packages
2 options:
- manually removing the line from the
composer.json
file and then runningcomposer update
(which will regenerate thecomposer.lock
file from the modifiedcomposer.json
- running
composer remove <package>
This is my output from trying to clean my composer.json
file.
$ composer remove symfony/polyfill-php80
./composer.json has been updated
Running composer update symfony/polyfill-php80
Loading composer repositories with package information
Updating dependencies
Nothing to modify in lock file
Writing lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Package fruitcake/laravel-cors is abandoned, you should avoid using it. No replacement was suggested.
Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead.
Generating optimized autoload files
74 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
No security vulnerability advisories found
Removal failed, symfony/polyfill-php80 is still present, it may be required by another package. See `composer why symfony/polyfill-php80`.
The lines that are important here:
- ./composer.json has been updated (it removed the dependency from your require array)
- Nothing to modify in lock file (this didn't change your dependencies)
- Removal failed, symfony/polyfill-php80 is still present, it may be required by another package. See
composer why symfony/polyfill-php80
. (this is exactly what I was talking about: the dependency is already required by something else, so it being in your composer.json only clutters it for no reason.
... And basically you have the long task ahead of you of cleaning up your composer.json file from most of those packages.
Also whenever you're unsure about what a composer command will do, you can append --dry-run
as an option. This will make the command just show the output without actually doing any changes.
答案2
得分: 0
"with alot of help from @IGP and @miken32\nI been able to install the needed packages.\n\nMy final composer.json looks like\n\n"require": {\n"php": "^8.2",\n"aws/aws-sdk-php": "^3.269",\n"elic-dev/laravel-site-protection": "^1.1",\n"guzzlehttp/guzzle": "^7.2",\n"laravel/framework": "^10.10",\n"laravel/sanctum": "^3.2",\n"laravel/tinker": "^2.8",\n"laravel/ui": "^4.2",\n"laravelcollective/html": "^6.4",\n"league/flysystem-aws-s3-v3": "^3.15",\n"spatie/laravel-permission": "^5.10",\n"spatie/laravel-sluggable": "^3.5"\n}"
英文:
with alot of help from @IGP and @miken32
I been able to install the needed packages.
My final composer.json looks like
"require": {
"php": "^8.2",
"aws/aws-sdk-php": "^3.269",
"elic-dev/laravel-site-protection": "^1.1",
"guzzlehttp/guzzle": "^7.2",
"laravel/framework": "^10.10",
"laravel/sanctum": "^3.2",
"laravel/tinker": "^2.8",
"laravel/ui": "^4.2",
"laravelcollective/html": "^6.4",
"league/flysystem-aws-s3-v3": "^3.15",
"spatie/laravel-permission": "^5.10",
"spatie/laravel-sluggable": "^3.5"
},
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论