How to upgrade symfony minor version (4.1 to 4.2)

邮差的信 提交于 2020-01-13 17:56:19

问题


I just want to know which is the proper way to upgrade symfony a minor version.

In the documentation https://symfony.com/doc/current/setup/upgrade_minor.html it says just to upgrade symfony/symfony package in composer, but I don't have this package, instead I have various symfony/framework-bundle, symfony/form, etc.

What I've done so far is to upgrade all symfony/XXX to the new version.

Also I had to create a new project with the 4.2 version in other folder, and copy the files .gitignore, public/index.php, config/bootstrap.php and src/kernel.php to the original project as these files has changed from 4.1 to 4.2, but I think this should not be the way to do it.

Should I have to remove all symfony/XX packages and replace them with symfony/symfony?

Will this upgrade also the files public/index.php, config/bootstra.php, etc?

Thank you


回答1:


In my case I was updating to 4.2 from 4.1.11 and some new files from 4.2 for some reason weren't automatically created. Also, there are a few changes in environment files that I consider very important.

I think the best and cleanest way to do this to do the following:

Instructions

  1. Update composer.json
"extra": {
    "symfony": {
        "allow-contrib": false,
        "require": "4.2.*"
    }
}
  1. Update dependencies composer update "symfony/*"
  2. Create a new config/bootstrap.php file with this code.
  3. Update public/index.php file with this code.
  4. Update .gitignore

Remove

###> symfony/framework-bundle ###
/.env

Add

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
  1. Rename .env to .env.local
  2. Rename .env.dist to .env

-- Update 30/05/19 --

  1. Update bin/console file with this code

Testing with PHPUnit

Follow this extra steps if you are using PHPUnit in your application (Recommended):

  1. Create a new .env.test and set your variables for test environment.
  2. Update phpunit.xml.dist with this code.

Important

You should notify about the environment files changes to your team and they should make a backup of their current configuration before pulling the changes because it will override the .env file.

If you need more information about this solution please read: https://symfony.com/doc/current/configuration/dot-env-changes.html




回答2:


Just check your composer.json. I just did same and only had to raise the minor. Then I’ve ran composer update and I succeeded.

I always follow the guides.

https://symfony.com/doc/current/setup/upgrade_minor.html https://github.com/symfony/symfony/blob/4.2/UPGRADE-4.2.md



来源:https://stackoverflow.com/questions/54241640/how-to-upgrade-symfony-minor-version-4-1-to-4-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!