将symfony升级到3.0 - 糟糕的分发包版本

时间:2015-12-23 17:40:30

标签: php composer-php symfony

我尝试从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

2 个答案:

答案 0 :(得分:2)

这是一个几乎与你有效的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"
        }
    }
}

答案 1 :(得分:1)

为了解决作曲家的这类问题,我建议你从composer.json中删除库,然后使用composer require。

  1. 删除"sensio/distribution-bundle": "~5.0"依赖关系
  2. 运行composer update
  3. 还是错误?与其他库重复1和2会导致错误。
  4. 没有错误?现在你的作曲家需要你删除的库:

    作曲家需要sensio / distribution-bundle

  5. 这样作曲家会为你找到最合适的套装。保持一个更稳定的作曲家json也很好!

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

    希望它有所帮助!