symfony sensio/框架额外捆绑包

问题描述 投票:0回答:1

我是 Symfony 的新手,正在 YouTube 上学习。我想尝试使用 sensio/framework-extra-bundle 带注释的路由,但是当我输入 Composer 命令来安装它时,出现一些错误。我询问了GPT并在Google上搜索了该问题的解决方案,但我找不到它。我做错了什么?

当我输入此内容时:

composer require sensio/framework-extra-bundle

我遇到了这个错误:

./composer.json has been updated
Running composer update sensio/framework-extra-bundle
Loading composer repositories with package information
Updating dependencies
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - sensio/framework-extra-bundle[v2.0.17, ..., v2.0.23] require symfony/framework-b
undle 2.0.* -> found symfony/framework-bundle[2.0.7, ..., v2.0.25] but it conflicts wi
th your root composer.json require (^7.0).
    - sensio/framework-extra-bundle[v2.1.0, ..., v2.1.11] require symfony/framework-bu
ndle 2.1.* -> found symfony/framework-bundle[v2.1.0, ..., v2.1.13] but it conflicts wi
th your root composer.json require (^7.0).
    - sensio/framework-extra-bundle v2.2.0 requires symfony/framework-bundle 2.2.* -> 
found symfony/framework-bundle[v2.2.0, ..., v2.2.11] but it conflicts with your root c
omposer.json require (^7.0).
    - sensio/framework-extra-bundle[v2.2.1, ..., v2.3.4] require symfony/framework-bun
dle ~2.2 -> found symfony/framework-bundle[v2.2.0, ..., v2.8.52] but it conflicts with
 your root composer.json require (^7.0).
    - sensio/framework-extra-bundle v3.0.0 requires symfony/framework-bundle ~2.4 -> f
ound symfony/framework-bundle[v2.4.0, ..., v2.8.52] but it conflicts with your root co
mposer.json require (^7.0).
    - sensio/framework-extra-bundle v3.0.1 requires symfony/framework-bundle ~2.5 -> f
ound symfony/framework-bundle[v2.5.0, ..., v2.8.52] but it conflicts with your root co
mposer.json require (^7.0).
    - sensio/framework-extra-bundle[v3.0.2, ..., v3.0.10] require symfony/framework-bu
ndle ~2.3 -> found symfony/framework-bundle[v2.3.0, ..., v2.8.52] but it conflicts wit
h your root composer.json require (^7.0).
    - sensio/framework-extra-bundle[v3.0.11, ..., v3.0.26] require symfony/framework-b
undle ~2.3|~3.0 -> found symfony/framework-bundle[v2.3.0, ..., v2.8.52, v3.0.0, ..., v
3.4.47] but it conflicts with your root composer.json require (^7.0).
    - sensio/framework-extra-bundle v3.0.24 requires symfony/config ^3.2 -> found symf
ony/config[v3.2.0, ..., v3.4.47] but it conflicts with your root composer.json require
 (v7.0.4).
    - sensio/framework-extra-bundle[v3.0.27, ..., v3.0.29] require symfony/framework-b
undle ~2.3|~3.0|~4.0 -> found symfony/framework-bundle[v2.3.0, ..., v2.8.52, v3.0.0, .
.., v3.4.47, v4.0.0, ..., v4.4.51] but it conflicts with your root composer.json requi
re (^7.0).
    - sensio/framework-extra-bundle[v4.0.0, v5.0.0, ..., v5.2.4] require symfony/confi
g ^3.3|^4.0 -> found symfony/config[v3.3.0, ..., v3.4.47, v4.0.0, ..., v4.4.44] but it
 conflicts with your root composer.json require (v7.0.4).
    - sensio/framework-extra-bundle[v5.3.0, ..., v5.3.1] require symfony/config ^3.4|^
4.2 -> found symfony/config[v3.4.0, ..., v3.4.47, v4.2.0, ..., v4.4.44] but it conflic
ts with your root composer.json require (v7.0.4).
    - sensio/framework-extra-bundle[v5.4.0, ..., v5.4.1] require symfony/config ^3.4|^
4.3 -> found symfony/config[v3.4.0, ..., v3.4.47, v4.3.0, ..., v4.4.44] but it conflic
ts with your root composer.json require (v7.0.4).
    - sensio/framework-extra-bundle[v5.5.0, ..., v5.5.3] require symfony/config ^4.3|^
5.0 -> found symfony/config[v4.3.0, ..., v4.4.44, v5.0.0, ..., v5.4.36] but it conflic
ts with your root composer.json require (v7.0.4).
    - sensio/framework-extra-bundle[v5.5.4, ..., v5.6.1, v6.0.0, ..., v6.1.5] require 
symfony/config ^4.4|^5.0 -> found symfony/config[v4.4.0, ..., v4.4.44, v5.0.0, ..., v5
.4.36] but it conflicts with your root composer.json require (v7.0.4).
    - sensio/framework-extra-bundle[v6.2.0, ..., v6.2.10] require symfony/config ^4.4|
^5.0|^6.0 -> found symfony/config[v4.4.0, ..., v4.4.44, v5.0.0, ..., v5.4.36, v6.0.0, 
..., v6.4.4] but it conflicts with your root composer.json require (v7.0.4).
    - Root composer.json requires sensio/framework-extra-bundle * -> satisfiable by se
nsio/framework-extra-bundle[v2.0.17, ..., v2.3.4, v3.0.0, ..., v3.0.29, v4.0.0, v5.0.0
, ..., v5.6.1, v6.0.0, ..., v6.2.10].

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals
 for packages currently locked to specific versions.
You can also try re-running composer require with an explicit version constraint, e.g.
 "composer require sensio/framework-extra-bundle:*" to figure out if any version is in
stallable, or "composer require sensio/framework-extra-bundle:^2.1" if you know which 
you need.

Installation failed, reverting ./composer.json and ./composer.lock to their original content.

这是我的composer.json 文件:

{
    "type": "project",
    "license": "proprietary",
    "minimum-stability": "stable",
    "prefer-stable": true,
    "require": {
        "php": ">=8.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "symfony/console": "~2.0|^5.0|^6.0|^7.0",
        "symfony/dotenv": "7.0.*",
        "symfony/flex": "^2",
        "symfony/framework-bundle": "^7.0",
        "symfony/runtime": "7.0.*",
        "symfony/yaml": "7.0.*",
        "symfony/config": "v7.0.4"
    },
    "require-dev": {
    },
    "config": {
        "allow-plugins": {
            "php-http/discovery": true,
            "symfony/flex": true,
            "symfony/runtime": true
        },
        "sort-packages": true
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php72": "*",
        "symfony/polyfill-php73": "*",
        "symfony/polyfill-php74": "*",
        "symfony/polyfill-php80": "*",
        "symfony/polyfill-php81": "*",
        "symfony/polyfill-php82": "*"
    },
    "scripts": {
        "auto-scripts": {
            "cache:clear": "symfony-cmd",
            "assets:install %PUBLIC_DIR%": "symfony-cmd"
        },
        "post-install-cmd": [
            "@auto-scripts"
        ],
        "post-update-cmd": [
            "@auto-scripts"
        ]
    },
    "conflict": {
        "symfony/symfony": "*"
    },
    "extra": {
        "symfony": {
            "allow-contrib": false,
            "require": "7.0.*"
        }
    }
}

我使用的PHP版本:

PHP 8.3.3 (cli)(构建时间:2024 年 2 月 13 日 23:17:12)(ZTS Visual C++ 2019 x64) 版权所有 (c) PHP 集团 Zend Engine v4.3.3,版权所有 (c) Zend Technologies

作曲家版本:

Composer版本2.7.2 2024-03-11 17:12:18 PHP 版本 8.3.3 (C:\php\php-8.3.3-Win32-vs16-x64\php.exe) 运行“diagnose”命令以获得更详细的诊断输出。

php laravel symfony composer-php
1个回答
0
投票

您不再需要这个捆绑包。

自 Symfony 6.2 起,SensioFrameworkExtraBundle 和 Annotations 已过时,不再建议使用。

https://symfony.com/bundles/SensioFrameworkExtraBundle/current/index.html

所有注释现已切换为属性。

https://symfony.com/doc/current/reference/attributes.html

如果你真的想使用注解,你需要降级Symfony本身。

© www.soinside.com 2019 - 2024. All rights reserved.