Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrade Symfony2 2.3 to 2.4: Change composer.json

I want to upgrade a project from Symfony 2.3 to 2.4. I've readed that the 2.4 version has backward compatibility with 2.3 and is only necessary to update de components version.

This is my 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"
            }
    }
}

But when I check the v2.4 composer.json file is very different from this.

I've tried to change my composer.json for the 2.4 version, add my custom bundles and make a "composer update", but it didn't work.

Would it be enough to update the versions of the bundles that installs the 2.4 version on my own composer.json?

Thanks.

like image 674
lenko Avatar asked Jan 14 '14 21:01

lenko


2 Answers

You're looking at the wrong composer.json. Try this one: https://github.com/symfony/symfony-standard/blob/2.4/composer.json

Explanation: The symfony/symfony repository is the framework itself -- but you do not want to clone the framework, only depend on it. That's why you'd rather use the symfony/symfony-standard repository, which is basically a template for projects that rely on the Symfony framework. As is yours.

like image 122
hanzi Avatar answered Oct 07 '22 03:10

hanzi


The new Symfony 2.4 composer.json file is next:

{
    "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"
        }
    }
}

Compare the third-party libraries in require section that You have used in your project with third-party libraries in v 2.4. If you don't use any missed libs in new version, you can update. But create a backup before.

like image 42
Victor Bocharsky Avatar answered Oct 07 '22 02:10

Victor Bocharsky