Yannick Pereira-Reis bio photo

Yannick Pereira-Reis

DevOps (docker swarm, haproxy, CI/CD, ELK, prometheus, grafana, ansible, automation, RabbitMQ, LVM, MySQL replication...) and fullstack web developer Symfony 2/3/4/5 + VueJs in Valence (France).

Twitter LinkedIn Github

If you want to upgrade your Symfony project to Symfony 3, you must check many different points. There is a page in the Symfony documentation that explains how to upgrade a major version.

Symfony

There are 3 steps to follow to succeed:

  • Make your Code Deprecation Free
  • Update to the New Major Version via Composer
  • Update your Code to Work with the New Version

Docker

I rencently built two docker images to give you more power to do your upgrades:

Tools

To help us to do upgrades, there are two tools we can use:

Analyzes your Symfony project and tries to make it compatible with the new version of Symfony framework.

Name Description
form_configure_options The method AbstractType::setDefaultOptions(OptionsResolverInterface $resolver) have been renamed to AbstractType::configureOptions(OptionsResolver $resolver).
form_events The events PRE_BIND, BIND and POST_BIND were renamed to PRE_SUBMIT, SUBMIT and POST_SUBMIT.
form_getname_to_getblockprefix The method FormTypeInterface::getName() was deprecated, you should now implement FormTypeInterface::getBlockPrefix() instead.
form_option_names Options precision and virtual was renamed to scale and inherit_data.
form_parent_type Returning type instances from FormTypeInterface::getParent() is deprecated, return the fully-qualified class name of the parent type class instead.
form_type_names Instead of referencing types by name, you should reference them by their fully-qualified class name (FQCN) instead.
get_request The getRequest method of the base controller class was removed, request object is injected in the action method instead.
inherit_data_aware_iterator The class VirtualFormAwareIterator was renamed to InheritDataAwareIterator.
progress_bar ProgressHelper has been removed in favor of ProgressBar.
property_access Renamed PropertyAccess::getPropertyAccessor to PropertyAccess::createPropertyAccessor.

The SensioLabs DeprecationDetector runs a static code analysis against your project’s source code to find usages of deprecated methods, classes and interfaces. For Symfony2 projects, it also detects usages of deprecated services. It identifies the use of deprecated code thanks to the @deprecated annotation.

## More…

Symfony 3 will be released at the end of November 2015. Learning from our own history, the transition from Symfony 2 to 3 will be much more pleasant than the transition from symfony 1 to 2 that happened in July 2011.

Ideally, your outside bundles are no longer triggering deprecated warnings. Now it’s time to update our code for Symfony 3. This means finding deprecation warnings, fixing them everywhere you can think of, and, well, repeating! It’s pretty simple, but sometimes the true source of a deprecation can be tricky to find.

First of all, PHP 5.5 is the new required version to run Symfony 3.0. Check that your servers are running 5.5 or newer PHP versions, if not consider upgrading PHP.