Posted on / by Vivan Web Solution / in Symfony Development

How to upgrade symfony version from 3.4 to symfony 4.4

Symfony 4: it’s a game changer. Honestly, I’ve never been so excited to start writing tutorials: you are going to love it!

Step 1: Remove Deprecations

look into your project at the bottom you got nav-bar of symfony, something like below.

This is nothing but Deprecations which shows, some functionality or services deprecated in new version, so it’s very important to remove all the listed deprecations before take next step. After removing all the deprecations please see the next step.

Step 2: Version Controller

Now, you are able to upgrade your project/application with the new symfony 4.4, the main changes you should have to do is, change the symfony version in composer.json file.

In older version till 3.4 we used `symfony/symfony` bundle , which is deprecated with `symfony/framework-bundle` in symfony 4.4 . Now we should use like below…

You can manage your version with below reference…

Step 3: Update Composer

After setting-up all deprecations & versions in composer.json, you just need to apply `composer update` command in cmd or git bash.

This command will update/install/remove all the dependencies which is used for described bundle in composer.json file, it’s take few minutes to update dependencies via composer.

Now your project is on symfony4.4 😊.

But still some main steps are remining.

Step 4: Moving to Symfony 4.4 directory structure

  • The var directory now holds the logs and cache files instead of app directory.
  • Create the directory in the root folder and move the files in it.
    • mkdir var
    • git mv app/cache var/
    • git mv app/logs var/
  • To update the project and the changes to take place, make the following changes in app/Appkernel.php
  • public function getRootDir() { return __DIR__; } public function getCacheDir() { return dirname(__DIR__).'/var/cache/'.$this->environment; } public function getLogDir() { return dirname(__DIR__).'/var/logs'; }

the folder structure something like below

Note :- Please use `git mv` command for change directory structure, do not directly move file via `copy/past` otherwise you’ll face file path in git repository. 

That’s all, you are now on symfony4.4, Enjoy your newest symfony version…✌.


Conclusion: I hope this tutorial helpful for you, if you have any issue regarding this blog, please comment below, we’ll be soon back to you.

Thank You!

 

 

Leave a Reply

×