简体   繁体   English

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

[英]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. 我有一个Symfony Web应用程序,需要从Symfony 2.6升级到3.4。 Is there a standardized, bare bones composer.json that shows what's necessary for the current version? 是否有一个标准的裸露的composer.json来显示当前版本的必要条件? 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. github上的演示应用文件似乎充满了一堆我不确定自己需要的额外东西。 Ideally, I'd like to update the existing composer.json and put out backwards compatibility fires where they may pop up. 理想情况下,我想更新现有的composer.json并在它们可能弹出的地方熄灭向后兼容。

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

Try running composer create-project symfony/framework-standard-edition - it will set up a bare bones project with the default composer.json . 尝试运行composer create-project symfony/framework-standard-edition它会使用默认的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. Symfony的升级指南包含有关您可能会弃用的有用信息。

That is not so easy. 那不是那么容易。 So first you can setup a new project with the symfony installer. 因此,首先您可以使用symfony安装程序设置一个新项目。

symfony new my_project

in the example project you have the actual composer.json you can use that version. 在示例项目中,您可以使用实际的composer.json版本。 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. 下一步是在升级指南中进行更改并更改所有新内容,并且从2.6到3.3进行了很多更改。 You can find the upgrade instructions in the repository. 您可以在存储库中找到升级说明。

https://github.com/symfony/symfony/blob/master/UPGRADE-3.0.md 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. 您必须解决所有问题并更改代码,直到再次起作用。

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

Symfony roadmap Symfony路线图

Currently, 2.8.22 is a long term support version. 当前,2.8.22是一个长期支持版本。 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). 这意味着您只需要从2.6更新到2.8,就可以适应一段时间(从安全和文档方面考虑)。

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. 它显示3.4比2.8更长的支持两年,但是LTS也很好。

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.6到2.8的大多数更改都必须达到3.4。

  • 2.8: 2.8:

    Nov 2018: End of support for bug fixes 2018年11月:终止对错误修复的支持

    Nov 2019: End of support for security fixes 2019年11月:不再支持安全修复程序

  • 3.4: 3.4:

    Nov 2020: End of support for bug fixes 2020年11月:终止对错误修复的支持

    Nov 2021: End of support for security fixes 2021年11月:不再支持安全修复程序

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM