About this post
This post explains how I approached the upgrade, and shows which parts of the project structure and code had to be changed in order to get the project working again.
Preparing the upgrade
The code base for the project – the CONTROL component of the JourneyMonitor project – lives at https://github.com/journeymonitor/control/. As you can see in an older revision of file composer.json, it was based on Symfony 2.6, and several other dependencies. In order to find out how exactly I would have to change the versions of these dependencies, I updated the Symfony Installer to the latest version and created a new Symfony 3.0 project via
symfony new foo 3.0 – it served as a reference only and was later thrown away. I compared its
composer.json file with the one from my project, and changed the latter accordingly. You can view the exact changes side-by-side at Github.
Afterwards, I ran
composer --with-dependencies update.
Changing the project structure
Symfony 3.0 introduces a new project directory structure. Some (but not all) of the stuff that used to live below
app/ now lives either in a new folder,
var/, or in
bin/. I git moved
bin/console, and then copied the
bin/console script from the foo project to
bin/console in my project. Then, I moved
var/SymfonyRequirements.php, and moved
Fixing the code
At this point, the project did not work anymore, and what followed was the grunt work of changing the code. You can see all changes that had to be made in this side-by-side diff. Here are some of the more interesting parts:
- Bootstrap form theming config changed
- _configurator route no longer exists
- security.yml: csrf_provider removed, remember_me “key” is now “secret”
- YAML files now expect quotes where they previously didn’t
- Forms are now created using class names instead of instances
- Form types now work with class names instead of strings
- The choice form element now expects the key-value mapping of its choices the other way round (thanks Craig Rayner for pointing this out)
- Service definitions for repositories changed a lot
- This makes the ominous Unknown “asset” function in “@Twig/Exception/exception_full.html.twig error go away
Finding the root cause of some of the errors did cost some nerves, but was worth it. At the end, the number of changes that had to be made turned out tractable. JourneyMonitor now happily hums along on top of Symfony 3.0.
Update December 14, 2015:
Although the project was running flawlessly after the changes described above, some minor changes were still missing.
At Symfony 2.6, the tests for the AppBundle live at
src/AppBundle/Tests, and they need to move to
tests/AppBundle. Accordingly, the namespace of the test classes changes from
Tests\AppBundle. See changeset c7f5f2c for details.
Another detail is that
AppKernel.php no longer needs to be required explicitly, and for the production environment, one should include the bootstrap cache. See changeset 90c9190 for details.