Skip to content

Commit

Permalink
Added new recipe on upgrading a major version
Browse files Browse the repository at this point in the history
  • Loading branch information
wouterj committed Apr 7, 2015
1 parent 8086af1 commit dac504a
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
1 change: 1 addition & 0 deletions cookbook/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@

* :doc:`/cookbook/upgrading/patch_version`
* :doc:`/cookbook/upgrading/minor_version`
* :doc:`/cookbook/upgrading/major_version`

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

Expand Down
1 change: 1 addition & 0 deletions cookbook/upgrade/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
95 changes: 95 additions & 0 deletions cookbook/upgrade/major_version.rst
Original file line number Diff line number Diff line change
@@ -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 <upgrade-major-symfony-deprecations>`;
#. :ref:`Update to the new major version via Composer <upgrade-major-symfony-composer>`.
#. :ref:`Update your code to work with the new version <upgrade-major-symfony-after>`

.. _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.

0 comments on commit dac504a

Please sign in to comment.