Skip to content

Commit dac504a

Browse files
committed
Added new recipe on upgrading a major version
1 parent 8086af1 commit dac504a

File tree

3 files changed

+97
-0
lines changed

3 files changed

+97
-0
lines changed

cookbook/map.rst.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@
205205

206206
* :doc:`/cookbook/upgrading/patch_version`
207207
* :doc:`/cookbook/upgrading/minor_version`
208+
* :doc:`/cookbook/upgrading/major_version`
208209

209210
* :doc:`/cookbook/validation/index`
210211

cookbook/upgrade/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ There are three types of upgrades, all needing a little different preparation:
1515

1616
/cookbook/upgrade/patch_version
1717
/cookbook/upgrade/minor_version
18+
/cookbook/upgrade/major_version

cookbook/upgrade/major_version.rst

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
.. index::
2+
single: Upgrading; Major Version
3+
4+
Upgrading a Major Version (e.g. 2.7.0 to 3.0.0)
5+
===============================================
6+
7+
Once in a couple years, Symfony releases a new major version release (the
8+
first number changes). These releases are the trickiest to upgrade, as they are
9+
allowed to contain BC breaks. However, Symfony tries to make this upgrade
10+
process as smooth as possible.
11+
12+
This means that you can update most of your code before the major release is
13+
actually released. This is called making your code *future compatible*.
14+
15+
There are a couple of steps to upgrading a major version:
16+
17+
#. :ref:`Make your code deprecation free <upgrade-major-symfony-deprecations>`;
18+
#. :ref:`Update to the new major version via Composer <upgrade-major-symfony-composer>`.
19+
#. :ref:`Update your code to work with the new version <upgrade-major-symfony-after>`
20+
21+
.. _upgrade-major-symfony-deprecations:
22+
23+
1) Make your Code Deprecation Free
24+
----------------------------------
25+
26+
During a lifecycle of a major release, new features are added and method
27+
signatures and public API usages are changed. However, minor versions should
28+
not contain any backwards compatibility changes. It is made sure that there is
29+
a so-called *backwards compatibility layer* (or BC layer). This means that the
30+
old API will still work, hile the new feature is used internally. This BC layer
31+
is then marked as *deprecated*, indicating that it will be removed/changed in
32+
the future.
33+
34+
The major version is the only time all existing BC layers are removed. The last
35+
minor version before a new major version (i.e. 2.7 is the last minor version of
36+
the 2 releases, 3.0 is the next version) will trigger deprecation notices when a
37+
BC layer is used.
38+
39+
When visiting your application in the dev environment in your browser, these
40+
notices are shown in the web dev toolbar:
41+
42+
.. image:: to be done
43+
44+
Deprecations in PHPunit
45+
~~~~~~~~~~~~~~~~~~~~~~~
46+
47+
By default, PHPunit will handle deprecation notices as real errors. This means
48+
that all tests are aborted because it uses a BC layer.
49+
50+
To make sure this doesn't happen, you can install the PhpUnit bridge:
51+
52+
.. code-block:: bash
53+
54+
$ composer require symfony/phpunit-bridge
55+
56+
Now, your tests will execute normally and a nice summary of the deprecation
57+
notices is displayed at the end of the test report:
58+
59+
.. _upgrade-major-symfony-composer:
60+
61+
2) Update to the New Major Version via Composer
62+
-----------------------------------------------
63+
64+
If your code is deprecation free, you can update the Symfony library via
65+
Composer by modifying your ``composer.json`` file:
66+
67+
.. code-block:: json
68+
69+
{
70+
"...": "...",
71+
72+
"require": {
73+
"symfony/symfony": "3.0.*",
74+
},
75+
"...": "...",
76+
}
77+
78+
Next, use Composer to download new versions of the libraries:
79+
80+
.. code-block:: bash
81+
82+
$ composer update symfony/symfony
83+
84+
.. include:: /cookbook/upgrade/_update_all_packages.rst.inc
85+
86+
.. _upgrade-major-symfony-after:
87+
88+
3) Update your Code to Work with the New Version
89+
------------------------------------------------
90+
91+
There is a high change that you're done now! However, the next major version
92+
*may* also contain new BC breaks as a BC layer is not always a possibility.
93+
Make sure you read the ``UPGRADE-X.0.md`` (where X is the new major version)
94+
included in the Symfony repository for any BC break that you need to be aware
95+
of.

0 commit comments

Comments
 (0)