Symfony2 LTS:如何从2.3升级到2.7? [英] Symfony2 LTS: how to upgrade from 2.3 to 2.7?
问题描述
Symfony 2.7是在2015年4月30日发布的,它是<在2.3版之后的href ="http://symfony.com/doc/current/contributing/community/releases.html#schedule" rel ="nofollow">当前LTS(长期支持)版本.这些版本的维护将于2016年5月针对Symfony 2.3终止,并于2018年5月针对Symfony 2.7终止.两种版本的维护终止后,将在一年内发布安全修补程序.
Symfony 2.7 was released on 30th April 2015 and is the current LTS (Long Term Support) version after the 2.3 version. Maintenance for these versions will end on May 2016 for Symfony 2.3 and May 2018 for Symfony 2.7. Security fixes will be released during one year after end of maintenance for both versions.
如 Massimiliano Arione所建议的那样,从Symfony 2.3从2.7升级而无需检查所有次要升级(2.3→2.4、2.4→2.5等)需要进行哪些更改?
As suggested by Massimiliano Arione in the announce comments, what are the changes required to upgrade from Symfony 2.3 from 2.7 without having to check all the minor upgrades (2.3 → 2.4, 2.4 → 2.5, etc.)?
推荐答案
正如Med在评论中所提醒的那样,Symfony2开发人员已尝试在2.x
分支中保持向后兼容性.因此,只要您以后不想切换到3.0
分支,就可以忽略2.3和2.7之间的更改,因为它们主要是弃用更改.
As reminded by Med in a comment, Symfony2 developers have tried to keep backward compatibility in the 2.x
branch. So as long as you don't want to switch to the 3.0
branch later, you can ignore the changes between 2.3 and 2.7 because they are mostly deprecation changes.
要将您的应用程序从Symfony 2.3升级到Symfony 2.7,您必须更新 composer.json 文件:
In order to upgrade you app from Symfony 2.3 to Symfony 2.7 you'll have to update your composer.json file:
([…]
表示代码不变)
旧版本( 2.3 )版本:
{
[…]
"autoload": {
"psr-0": { "": "src/" }
},
"require": {
"php": ">=5.3.3",
"symfony/symfony": "2.3.*",
"doctrine/orm": "~2.2,>=2.2.3,<2.5",
"doctrine/dbal": "<2.5",
"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": "~3.0,>=3.0.2",
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"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::prepareDeploymentTarget"
]
},
[…]
"minimum-stability": "stable",
"extra": {
[…]
"incenteev-parameters": {
"file": "app/config/parameters.yml"
},
"branch-alias": {
"dev-master": "2.3-dev"
}
}
}
新版本( 2.7 )版本:
{
[…]
"autoload": {
"psr-4": { "": "src/", "SymfonyStandard\\": "app/SymfonyStandard/" }
},
"require": {
"php": ">=5.3.9",
"symfony/symfony": "2.7.*",
"doctrine/orm": "^2.4.8",
"doctrine/doctrine-bundle": "~1.4",
"symfony/assetic-bundle": "~2.3",
"symfony/swiftmailer-bundle": "~2.3",
"symfony/monolog-bundle": "~2.4",
"sensio/distribution-bundle": "~4.0",
"sensio/framework-extra-bundle": "^3.0.2",
"incenteev/composer-parameter-handler": "~2.0"
},
"require-dev": {
"sensio/generator-bundle": "~2.3",
"symfony/phpunit-bridge": "~2.7"
},
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::removeSymfonyStandardFiles",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
],
"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",
"Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
]
},
[…]
"extra": {
[…]
"symfony-assets-install": "relative",
[…]
"branch-alias": {
"dev-master": "2.7-dev"
}
}
}
摘要:
- Symfony版本已更新 使用
-
PSR-4
代替PSR-0
-
twig/extensions
默认情况下未安装,如果您使用Twig扩展名,则可能需要添加它 -
sensio/generator-bundle
仅在dev
环境中是必需的 -
scripts
部分已更新 -
"minimum-stability": "stable",
已被删除
- Symfony version is updated
PSR-4
is used instead ofPSR-0
twig/extensions
is not installed by default, you may need to add it if you use Twig extensionssensio/generator-bundle
is required only indev
environmentscripts
part has been updated"minimum-stability": "stable",
has been removed
一旦更新了 composer.json 文件,就必须更新依赖项:
Once you have updated your composer.json file, you have to update the dependencies:
composer update --prefer-dist -vv
然后您可能需要刷新缓存:
Then you may need to flush the cache:
php app/console cache:clear --env=dev
注意:我使用以下命令来获取 composer.json 文件:
Note: I used the following command in order to get the composer.json files:
# create Symfony "2.3.*" project in the "2.3" directory
composer create-project symfony/framework-standard-edition "2.3" "2.3.*" --no-interaction -v
# create Symfony "2.7.*" project in the "2.7" directory
composer create-project symfony/framework-standard-edition "2.7" "2.7.*" --no-interaction -v
# compare the Symfony 2.3 and 2.7 composer.json files
diff -u 2.3/composer.json 2.7/composer.json
(我们使用2.3.*
而不是2.3
,因为我们想要的是最新版本(今天是2.3.31
),而不是初始版本(2.3.0
))
(we use 2.3.*
and not 2.3
because we want the last version (2.3.31
today) and not the initial release (2.3.0
))
diff也可从 GitHub 获得,但是
The diff is available at GitHub too, but the composer.json file of Symfony 2.3 has been updated multiple times, so it may be different from your file.
这篇关于Symfony2 LTS:如何从2.3升级到2.7?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!