diff --git a/cookbook/map.rst.inc b/cookbook/map.rst.inc index 92bc715cee4..17c61fbb110 100644 --- a/cookbook/map.rst.inc +++ b/cookbook/map.rst.inc @@ -205,6 +205,7 @@ * :doc:`/cookbook/upgrading/patch_version` * :doc:`/cookbook/upgrading/minor_version` + * :doc:`/cookbook/upgrading/major_version` * :doc:`/cookbook/validation/index` diff --git a/cookbook/upgrade/index.rst b/cookbook/upgrade/index.rst index fe4aeca3b4e..b943f2ae32a 100644 --- a/cookbook/upgrade/index.rst +++ b/cookbook/upgrade/index.rst @@ -15,3 +15,4 @@ There are three types of upgrades, all needing a little different preparation: /cookbook/upgrade/patch_version /cookbook/upgrade/minor_version + /cookbook/upgrade/major_version diff --git a/cookbook/upgrade/major_version.rst b/cookbook/upgrade/major_version.rst new file mode 100644 index 00000000000..79be26cbcde --- /dev/null +++ b/cookbook/upgrade/major_version.rst @@ -0,0 +1,95 @@ +.. index:: + single: Upgrading; Major Version + +Upgrading a Major Version (e.g. 2.7.0 to 3.0.0) +=============================================== + +Once in a couple years, Symfony releases a new major version release (the +first number changes). These releases are the trickiest to upgrade, as they are +allowed to contain BC breaks. However, Symfony tries to make this upgrade +process as smooth as possible. + +This means that you can update most of your code before the major release is +actually released. This is called making your code *future compatible*. + +There are a couple of steps to upgrading a major version: + +#. :ref:`Make your code deprecation free `; +#. :ref:`Update to the new major version via Composer `. +#. :ref:`Update your code to work with the new version ` + +.. _upgrade-major-symfony-deprecations: + +1) Make your Code Deprecation Free +---------------------------------- + +During a lifecycle of a major release, new features are added and method +signatures and public API usages are changed. However, minor versions should +not contain any backwards compatibility changes. It is made sure that there is +a so-called *backwards compatibility layer* (or BC layer). This means that the +old API will still work, hile the new feature is used internally. This BC layer +is then marked as *deprecated*, indicating that it will be removed/changed in +the future. + +The major version is the only time all existing BC layers are removed. The last +minor version before a new major version (i.e. 2.7 is the last minor version of +the 2 releases, 3.0 is the next version) will trigger deprecation notices when a +BC layer is used. + +When visiting your application in the dev environment in your browser, these +notices are shown in the web dev toolbar: + +.. image:: to be done + +Deprecations in PHPunit +~~~~~~~~~~~~~~~~~~~~~~~ + +By default, PHPunit will handle deprecation notices as real errors. This means +that all tests are aborted because it uses a BC layer. + +To make sure this doesn't happen, you can install the PhpUnit bridge: + +.. code-block:: bash + + $ composer require symfony/phpunit-bridge + +Now, your tests will execute normally and a nice summary of the deprecation +notices is displayed at the end of the test report: + +.. _upgrade-major-symfony-composer: + +2) Update to the New Major Version via Composer +----------------------------------------------- + +If your code is deprecation free, you can update the Symfony library via +Composer by modifying your ``composer.json`` file: + +.. code-block:: json + + { + "...": "...", + + "require": { + "symfony/symfony": "3.0.*", + }, + "...": "...", + } + +Next, use Composer to download new versions of the libraries: + +.. code-block:: bash + + $ composer update symfony/symfony + +.. include:: /cookbook/upgrade/_update_all_packages.rst.inc + +.. _upgrade-major-symfony-after: + +3) Update your Code to Work with the New Version +------------------------------------------------ + +There is a high change that you're done now! However, the next major version +*may* also contain new BC breaks as a BC layer is not always a possibility. +Make sure you read the ``UPGRADE-X.0.md`` (where X is the new major version) +included in the Symfony repository for any BC break that you need to be aware +of.