How I migrate Symfony 4.4 to 5.4 in legacy app

Petr Lzicar
2 min readJul 1, 2022

--

We are using Symfony FW from version 2.x, so we have lots of code, which is with us for several yers. Because end of lifecycle 4.x version is coming, I have to do upgrade, which is always fun :). In this article i want to mention some points, which can helps next Devs with this task.

Twigs templates

We have several bundles and from history reason we are using historical notation: {% extends ‘AppBundle::layout.html.twig’ %} which is not working in 5.x SF. New format is: {% extends ‘@App/layout.html.twig’ %}. Btw don't forgot to register all bundles in config under paths in twig section.

Twig config after update

config.yml

  • %kernel.root_dir% is not exists anymore, need to change it to %kernel.project_dir% and fix all paths.
  • templating property is not exists anymore
  • if you are using encore, then you have to add json_manifest_path under assets in framework section.

Memcache

We had used MemcachedCache for custom caching function, which is deprecated and in new symfony not exist anymore. As substitute i used MemcachedAdapter

Result of using MemcachedAdapter as custom cache provider

TranChoice

Just replace with trans() method witch count parameter. Good resource is here.

Solr

We are using NelmioSolarium Bundle, so i had to change path parameter and add core parameter. Something like this:

path:"/solr/myData"

to:

path: "/"
core: myData

And here is my reward after a week of detective work. To be honest i cannot done it without tests…. thanks god for it :)

Thanks for reading!

--

--

Petr Lzicar
Petr Lzicar

Written by Petr Lzicar

I'm react-native and iOS developer

No responses yet