【问题标题】:Upgrade Symfony2 2.3 to 2.4: Change composer.json将 Symfony2 2.3 升级到 2.4:更改 composer.json
【发布时间】:2014-01-14 21:07:00
【问题描述】:

我想将项目从 Symfony 2.3 升级到 2.4。我读过 2.4 版本向后兼容 2.3 并且只需要更新 de components 版本。

这是我的 composer.json:

{
    "name" : "symfony/framework-standard-edition",
    "description" : "The \"Symfony Standard Edition\" distribution",
    "type" : "project",
    "license" : [
            "MIT"
    ],
    "require" : {
            "symfony/symfony" : "2.3.*",
            "doctrine/doctrine-fixtures-bundle" : "dev-master",
            "symfony/swiftmailer-bundle" : "2.3.*",
            "doctrine/orm" : ">=2.2.3,<2.4-dev",
            "doctrine/data-fixtures" : "dev-master",
            "symfony/assetic-bundle" : "2.3.*",
            "incenteev/composer-parameter-handler" : "~2.0",
            "twig/extensions" : "1.0.*",
            "php" : ">=5.3.3",
            "sensio/generator-bundle" : "2.3.*",
            "symfony/monolog-bundle" : "2.4.*",
            "sensio/framework-extra-bundle" : "2.3.*",
            "doctrine/doctrine-bundle" : "1.2.*",
            "sensio/distribution-bundle" : "2.3.*",
            "liip/imagine-bundle": "dev-master",
            "egeloen/google-map-bundle": "*"
    },
    "autoload" : {
            "psr-0" : {
                    "" : "src/"
            }
    },
    "minimum-stability" : "stable",
    "config" : {
            "bin-dir" : "bin"
    },
    "scripts" : {
            "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"
            ],
            "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"
            ]
    },
    "extra" : {
            "branch-alias" : {
                    "dev-master" : "2.3-dev"
            },
            "symfony-web-dir" : "web",
            "symfony-app-dir" : "app",
            "incenteev-parameters" : {
                    "file" : "app/config/parameters.yml"
            }
    }
}

但是当我检查the v2.4 composer.json file 时与此有很大不同。

我尝试将我的 composer.json 更改为 2.4 版本,添加我的自定义包并进行“composer update”,但没有成功。

更新在我自己的 composer.json 上安装 2.4 版本的捆绑包的版本就足够了吗?

谢谢。

【问题讨论】:

    标签: php symfony composer-php


    【解决方案1】:

    你看错了composer.json。试试这个: https://github.com/symfony/symfony-standard/blob/2.4/composer.json

    说明:symfony/symfony 存储库是框架本身——但您不想克隆框架,只依赖它。这就是为什么您宁愿使用symfony/symfony-standard 存储库,它基本上是依赖于 Symfony 框架的项目的模板。和你一样。

    【讨论】:

    • 谢谢@hanzi。现在我了解了 Symfony github 的组织方式。
    【解决方案2】:

    接下来是新的 Symfony 2.4 composer.json 文件:

    {
        "name": "symfony/framework-standard-edition",
        "license": "MIT",
        "type": "project",
        "description": "The \"Symfony Standard Edition\" distribution",
        "autoload": {
            "psr-0": { "": "src/" }
        },
        "require": {
            "php": ">=5.3.3",
            "symfony/symfony": "~2.4",
            "doctrine/orm": "~2.2,>=2.2.3",
            "doctrine/doctrine-bundle": "~1.2",
            "twig/extensions": "~1.0",
            "symfony/assetic-bundle": "~2.3",
            "symfony/swiftmailer-bundle": "~2.3",
            "symfony/monolog-bundle": "~2.4",
            "sensio/distribution-bundle": "~2.3",
            "sensio/framework-extra-bundle": "~2.3",
            "sensio/generator-bundle": "~2.3",
            "incenteev/composer-parameter-handler": "~2.0"
        },
        "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"
            ],
            "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"
            ]
        },
        "config": {
            "bin-dir": "bin"
        },
        "minimum-stability": "beta",
        "extra": {
            "symfony-app-dir": "app",
            "symfony-web-dir": "web",
            "incenteev-parameters": {
                "file": "app/config/parameters.yml"
            },
            "branch-alias": {
                "dev-master": "2.4-dev"
            }
        }
    }
    

    将您在项目中使用的 require 部分中的第三方库与 v 2.4 中的第三方库进行比较。如果您在新版本中没有使用任何遗漏的库,您可以更新。但之前创建一个备份。

    【讨论】:

    • 有了这个 composer.json,更新工作完美。我只需要添加我的自定义包和“doctrine/data-fixtures”+“doctrine/doctrine-fixtures-bundle”。谢谢。
    • 不客气。 @hanzi 下面还给出了 github 上 symfony-standard-editin 的 composer.json 文件的链接,我在我的示例中给出了这个链接。
    猜你喜欢
    • 2014-02-02
    • 1970-01-01
    • 1970-01-01
    • 2015-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-16
    • 1970-01-01
    相关资源
    最近更新 更多