Major Productions
Major Productions

Reputation: 6042

Symfony - upgrading an old project (v 2.6) to 3.4

I have a Symfony web app that needs to be upgraded from Symfony 2.6 to 3.4. Is there a standardized, bare bones composer.json that shows what's necessary for the current version? The demo app's file on github seems to be filled with a bunch of extra things that I'm not entirely sure I need. Ideally, I'd like to update the existing composer.json and put out backwards compatibility fires where they may pop up.

EDIT: my current composer is -

{
    "license": "Private",
    "type": "project",
    "description": "Home/e-commerce site",
    "autoload": {
        "psr-0": { "": "src/", "SymfonyStandard": "app/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.6.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "2.6.*",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~3.0",
        "sensio/framework-extra-bundle": "~3.0",
        "incenteev/composer-parameter-handler": "~2.0",
        "jms/security-extra-bundle": "dev-master",
        "jms/di-extra-bundle": "dev-master",
        "friendsofsymfony/user-bundle": "2.0.*@dev",
        "roave/security-advisories": "dev-master"
    },
    "require-dev": {
        "sensio/generator-bundle": "~2.3"
    },
    "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",
            "keep-outdated": true
        },
        "branch-alias": {
            "dev-master": "2.6-dev"
        }
    }
}

Upvotes: 2

Views: 2124

Answers (3)

Jonathan
Jonathan

Reputation: 15432

Try running composer create-project symfony/framework-standard-edition - it will set up a bare bones project with the default composer.json. Here's what that looks like:

{
    "name": "name",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        },
        "files": [
            "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php"
        ]
    },
    "require": {
        "php": ">=5.5.9",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/orm": "^2.5",
        "incenteev/composer-parameter-handler": "^2.0",
        "sensio/distribution-bundle": "^5.0.19",
        "sensio/framework-extra-bundle": "^3.0.2",
        "symfony/monolog-bundle": "^3.1.0",
        "symfony/polyfill-apcu": "^1.0",
        "symfony/swiftmailer-bundle": "^2.3.10",
        "symfony/symfony": "3.3.*",
        "twig/twig": "^1.0||^2.0"
    },
    "require-dev": {
        "sensio/generator-bundle": "^3.0",
        "symfony/phpunit-bridge": "^3.0"
    },
    "scripts": {
        "symfony-scripts": [
            "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-install-cmd": [
            "@symfony-scripts"
        ],
        "post-update-cmd": [
            "@symfony-scripts"
        ]
    },
    "config": {
        "sort-packages": true
    },
    "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": null
    }
}

Symfony's upgrade guide contains useful information on the deprecations you may encounter.

Upvotes: 3

pid
pid

Reputation: 11607

Unless you really need to go for 3.* (PHP 7 or other reasons for which you can not choose the version), you can update to the LTS version instead:

Symfony roadmap

Currently, 2.8.22 is a long term support version. This means you need only to update from 2.6 to 2.8 and you'll be fine for some time (security and documentation wise).

For specific details you can use the version checker on the page above. It shows that 3.4 is supported for 2 years longer than 2.8, but the LTS is also perfectly fine.

Consider your specific case IF going smaller steps may be a better choice. Most changes from 2.6 to 2.8 are necessary to get to 3.4, anyways.

  • 2.8:

    Nov 2018: End of support for bug fixes

    Nov 2019: End of support for security fixes

  • 3.4:

    Nov 2020: End of support for bug fixes

    Nov 2021: End of support for security fixes

Upvotes: 1

René Höhle
René Höhle

Reputation: 27295

That is not so easy. So first you can setup a new project with the symfony installer.

symfony new my_project

in the example project you have the actual composer.json you can use that version. Next step is to look at all your extensions if they are the latest version. Next step is to at the upgrade guides what have changed and change all that new things and from 2.6 to 3.3 there is a lot of stuf that have changed. You can find the upgrade instructions in the repository.

https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md

for example. You have to fix all problems and change your code until it's working again.

Upvotes: 1

Related Questions