Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upgrade symfony minor version (4.1 to 4.2)

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

like image 718
David Rojo Avatar asked Jan 01 '23 10:01

David Rojo


1 Answers

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

like image 70
Williams A. Avatar answered Jan 05 '23 06:01

Williams A.