A.L*_*A.L 4 upgrade symfony symfony-2.3 symfony-2.7
Symfony 2.7于2015年4月30日发布,是2.3版本之后的当前LTS(长期支持)版本.这些版本的维护将于2016年5月针对Symfony 2.3和2018年5月针对Symfony 2.7进行.安全修复程序将在两个版本的维护结束后一年内发布.
正如Massimiliano Arione在宣布评论中所建议的那样,从Symfony 2.3升级到2.7需要进行哪些更改而无需检查所有次要升级(2.3→2.4,2.4→2.5等)?
A.L*_*A.L 26
正如Med在评论中提醒的那样,Symfony2开发人员试图在2.x分支中保持向后兼容性.因此,只要您3.0以后不想切换到分支,就可以忽略2.3和2.7之间的更改,因为它们主要是弃用更改.
为了将您的应用程序从Symfony 2.3升级到Symfony 2.7,您必须更新您的composer.json文件:
([…]表示代码不变)
旧(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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
新(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"
}
}
}
Run Code Online (Sandbox Code Playgroud)
摘要:
PSR-4 用来代替 PSR-0twig/extensions 默认情况下不安装,如果使用Twig扩展,则可能需要添加它sensio/generator-bundle仅在dev环境中需要scripts 部分已更新"minimum-stability": "stable", 已被删除更新composer.json文件后,必须更新依赖项:
composer update --prefer-dist -vv
Run Code Online (Sandbox Code Playgroud)
然后您可能需要刷新缓存:
php app/console cache:clear --env=dev
Run Code Online (Sandbox Code Playgroud)
注意:我使用以下命令来获取composer.json文件:
# 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
Run Code Online (Sandbox Code Playgroud)
(我们使用2.3.*而不是2.3因为我们想要最后一个版本(2.3.31今天)而不是初始版本(2.3.0))
差异也可以在GitHub上获得,但composer.jsonSymfony 2.3 的文件已经多次更新,因此它可能与您的文件不同.
| 归档时间: |
|
| 查看次数: |
8817 次 |
| 最近记录: |