Symfony - 将旧项目(v 2.6)升级到3.4

时间:2017-06-22 19:27:28

标签: php symfony

我有一个Symfony网络应用程序,需要从Symfony 2.6升级到3.4。是否有标准化的裸骨composer.json,显示当前版本的必要条件? github上的演示应用程序文件似乎充满了一些我不完全确定需要的额外内容。理想情况下,我想更新现有的composer.json并向后弹出可能会弹出的向后兼容性火灾。

编辑:我现在的作曲家是 -

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

3 个答案:

答案 0 :(得分:3)

尝试运行composer create-project symfony/framework-standard-edition - 它将设置一个带有默认composer.json的裸骨骼项目。这是什么样的:

{
    "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的upgrade guide包含有关您可能遇到的弃用的有用信息。

答案 1 :(得分:1)

这并不容易。首先,您可以使用symfony安装程序设置新项目。

symfony new my_project

在示例项目中,您可以使用该版本的实际composer.json。下一步是查看所有扩展,如果它们是最新版本。下一步是在升级指南中更改并更改所有新内容,从2.6到3.3,有很多stuf已更改。您可以在存储库中找到升级说明。

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

例如,

。您必须解决所有问题并更改代码,直到它再次运行。

答案 2 :(得分:1)

除非您确实需要使用3. *(PHP 7或其他无法选择版本的原因),否则您可以更新为LTS版本:

Symfony roadmap

目前,2.8.22是长期支持版本。这意味着您只需要从2.6更新到2.8,并且您可以在一段时间内完成(安全性和文档明智)。

有关具体细节,您可以使用上面页面上的版本检查器。它表明3.4支持2年超过2.8,但LTS也非常好。

考虑您的具体情况 IF 更小的步骤可能是更好的选择。无论如何,从2.6到2.8的大多数变化都是必要的。

  • 2.8:

    2018年11月:对错误修复的支持终止

    2019年11月:对安全修复的支持终止

  • 3.4:

    2020年11月:对错误修复的支持终止

    2021年11月:对安全修复的支持终止