【问题标题】:Upgrading symfony to 3.0 - bad distribution-bundle version将 symfony 升级到 3.0 - 错误的分发包版本
【发布时间】:2015-12-23 17:40:29
【问题描述】:

我正在尝试从 symfony 2.7 升级到 3.0。根据one,我使我的代码免于弃用并使用新的软件包版本更新composer.json。当我使用命令开始升级时:composer update --with-dependencies symfony/symfony 它给了我如下错误:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package sensio/distribution-bundle == 4.0.4.0 could not be found.
  Problem 2
    - The requested package sensio/generator-bundle == 2.5.3.0 could not be found.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

我不知道这两个软件包的这些奇怪版本是从哪里来的。我的composer.json 看起来像:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/", "SymfonyStandard": "app/" }
    },
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.0.*",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.8",
        "sensio/distribution-bundle": "~5.0",
        "sensio/framework-extra-bundle": "~3.0.2",
        "incenteev/composer-parameter-handler": "~2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0"
    },
    "scripts": {
        "post-root-package-install": [
            "SymfonyStandard\\Composer::hookRootPackageInstall"
        ],
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.0-dev"
        },
        "symfony-assets-install": "symlink"
    }
}

我看不到哪里出错了,有什么建议吗?

编辑:

只执行composer update 而不是composer update --with-dependencies symfony/symfony 似乎可以解决问题,所有包更新成功,然后显示:

[RuntimeException]
An error occurred when executing the "'cache:clear --no-warmup'" command:
Fatal error: Class 'Symfony\Component\Console\Input\ArgvInput' not found in /home/wombat/htdocs/gugupanel/app/console on line 17

【问题讨论】:

  • 对 sensio 库使用 ^ 而不是 ~。懒得查找差异,但它们为我安装干净,这就是 S3 composer.json 使用的。准备好有很多很多的形式问题。先去2.8可能会更好。
  • @Cerad - 将 ~ 更改为 ^ 没有任何区别,同样的错误。

标签: php composer-php symfony


【解决方案1】:

这是一个几乎与你的匹配的 composer.json,它对我有用。

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-4": { "": "src/" },
        "files": [ "app/AppKernel.php" ]
    },
    "autoload-dev": {
        "psr-4": { "Tests\\": "tests/" }
    },
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.0.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "phpunit/phpunit": "^4.8",
        "sensio/generator-bundle": "^3.0"
    },
    "require-dev": {
        "symfony/phpunit-bridge": "^2.7"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-bin-dir": "bin",
        "symfony-var-dir": "var",
        "symfony-web-dir": "web",
        "symfony-tests-dir": "tests",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "3.0-dev"
        }
    }
}

【讨论】:

    【解决方案2】:

    为了解决 composer 的此类问题,我建议您从 composer.json 中删除该库,然后使用 composer require。

    1. 删除"sensio/distribution-bundle": "~5.0" 依赖项
    2. 运行作曲家更新
    3. 还有错误吗?对导致错误的其他库重复 1 和 2。
    4. 没有错误?现在您的作曲家需要您删除的库:

      composer 需要 sensio/distribution-bundle

    这样作曲家会找到最适合你的。保持更稳定的composer json也不错!

    不要忘记在所有更新正常后提交您的composer.lock 文件,这样其他开发人员将使用与您相同的版本。

    希望对你有帮助!

    【讨论】:

    • 删除distribution-bundle 依赖导致更多错误,几乎所有已安装的库。删除了整个供应商目录,composer.lock 文件以再次安装所有内容,但仍然只是一大包错误。那个作曲家的东西是废话......
    • 删除分发包时出现什么错误?
    • 这是一个很长的- don't install symfony/process v2.6.8|don't install symfony/symfony v3.0.0 列表和不同版本的symfony/process- sensio/distribution-bundle v4.0.4 requires symfony/process ~2.2 -&gt; 以及另一个很长的不同版本列表。
    • 是的。除非您正确使用 Composer,否则它是垃圾。要是你有一个工作文件的例子就好了。
    • 据我所知,这是唯一有效的解决方案。我曾尝试手动跟上正确的软件包版本,但那是我醒来的噩梦。
    猜你喜欢
    • 2023-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-23
    • 2014-02-20
    • 2020-09-13
    • 1970-01-01
    相关资源
    最近更新 更多