-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documented upgrading path for a major version #5155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6a90c9b
2b0aee3
300e8ab
99c5075
55fcee9
31999db
604ccab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
You may also want to upgrade the rest of your libraries. If you've done a | ||
good job with your `version constraints`_ in ``composer.json``, you can do | ||
this safely by running: | ||
|
||
.. code-block:: bash | ||
|
||
$ composer update | ||
|
||
.. caution:: | ||
|
||
Beware, if you have some unspecific `version constraints`_ in your | ||
``composer.json`` (e.g. ``dev-master``), this could upgrade some | ||
non-Symfony libraries to new versions that contain backwards-compatibility | ||
breaking changes. | ||
|
||
.. _`version constraints`: https://getcomposer.org/doc/01-basic-usage.md#package-versions |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
.. index:: | ||
single: Upgrading | ||
|
||
Upgrading | ||
========= | ||
|
||
So a new Symfony release has come out and you want to upgrade, great! Fortunately, | ||
because Symfony protects backwards-compatibility very closely, this *should* | ||
be quite easy. | ||
|
||
There are three types of upgrades, all needing a little different preparation: | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
/cookbook/upgrade/patch_version | ||
/cookbook/upgrade/minor_version | ||
/cookbook/upgrade/major_version | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
.. index:: | ||
single: Upgrading; Major Version | ||
|
||
Upgrading a Major Version (e.g. 2.7.0 to 3.0.0) | ||
=============================================== | ||
|
||
Every few 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your |
||
---------------------------------- | ||
|
||
During the lifecycle of a major release, new features are added and method | ||
signatures and public API usages are changed. However, | ||
:doc:`minor versions </cookbook/upgrade/minor_version>` should not contain any | ||
backwards compatibility changes. To accomplish this, the "old" (e.g. functions, | ||
classes, etc) code still works, but is marked as *deprecated*, indicating that | ||
it will be removed/changed in the future and that you should stop using it. | ||
|
||
When the major version is released (e.g. 3.0.0), all deprecated features and | ||
functionality are removed. So, as long as you've updated your code to stop | ||
using these deprecated features in the last version before the major (e.g. | ||
2.8.*), you should be able to upgrade without a problem. | ||
|
||
To help you with this, the last minor releases will trigger deprecated notices. | ||
For example, 2.7 and 2.8 trigger deprecated notices. When visiting your | ||
application in the :doc:`dev environment </cookbook/configuration/environments>` | ||
in your browser, these notices are shown in the web dev toolbar: | ||
|
||
.. image:: /images/cookbook/deprecations-in-profiler.png | ||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently, this will not work as the PHPUnit bridge was not part of a stable release yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it will once 2.7 is stable and will be used as current. And as it's in a couple of weeks, I don't think it's usefull to have |
||
|
||
Now, your tests execute normally and a nice summary of the deprecation notices | ||
is displayed at the end of the test report: | ||
|
||
.. code-block:: text | ||
|
||
$ phpunit | ||
... | ||
|
||
OK (10 tests, 20 assertions) | ||
|
||
Remaining deprecation notices (6) | ||
|
||
The "request" service is deprecated and will be removed in 3.0. Add a typehint for | ||
Symfony\Component\HttpFoundation\Request to your controller parameters to retrieve the | ||
request instead: 6x | ||
3x in PageAdminTest::testPageShow from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin | ||
2x in PageAdminTest::testPageList from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin | ||
1x in PageAdminTest::testPageEdit from Symfony\Cmf\SimpleCmsBundle\Tests\WebTest\Admin | ||
|
||
.. _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.*", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to recommend There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the upgrading articles, we've used My Composer rule is always: Keep version ranges as big as possible when developing 3th party libraries and as small as possible for your projects. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with @wouterj. The user should be aware when updating to a new minor version and not get this implicitly in their applications. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just follow the standard edition which - for whatever reason - uses the |
||
}, | ||
"...": "...", | ||
} | ||
|
||
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 was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. According to wikipedia (and other sources), determiners are part of the closed class words:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's interesting. I thought it wasn't because it's based on "you". But apparently, you are right. |
||
------------------------------------------------ | ||
|
||
There is a good chance 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
.. index:: | ||
single: Upgrading; Minor Version | ||
|
||
Upgrading a Minor Version (e.g. 2.5.3 to 2.6.1) | ||
=============================================== | ||
|
||
If you're upgrading a minor version (where the middle number changes), then | ||
you should *not* encounter significant backwards compatibility changes. For | ||
details, see the :doc:`Symfony backwards compatibility promise </contributing/code/bc>`. | ||
|
||
However, some backwards-compatibility breaks *are* possible and you'll learn in | ||
a second how to prepare for them. | ||
|
||
There are two steps to upgrading a minor version: | ||
|
||
#. :ref:`Update the Symfony library via Composer <upgrade-minor-symfony-composer>`; | ||
#. :ref:`Update your code to work with the new version <upgrade-minor-symfony-code>`. | ||
|
||
.. _`upgrade-minor-symfony-composer`: | ||
|
||
1) Update the Symfony Library via Composer | ||
------------------------------------------ | ||
|
||
First, you need to update Symfony by modifying your ``composer.json`` file | ||
to use the new version: | ||
|
||
.. code-block:: json | ||
|
||
{ | ||
"...": "...", | ||
|
||
"require": { | ||
"symfony/symfony": "2.6.*", | ||
}, | ||
"...": "...", | ||
} | ||
|
||
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-minor-symfony-code`: | ||
|
||
2) Updating your Code to Work with the new Version | ||
-------------------------------------------------- | ||
|
||
In theory, you should be done! However, you *may* need to make a few changes | ||
to your code to get everything working. Additionally, some features you're | ||
using might still work, but might now be deprecated. While that's just fine, | ||
if you know about these deprecations, you can start to fix them over time. | ||
|
||
Every version of Symfony comes with an UPGRADE file (e.g. `UPGRADE-2.7.md`_) | ||
included in the Symfony directory that describes these changes. If you follow | ||
the instructions in the document and update your code accordingly, it should be | ||
safe to update in the future. | ||
|
||
These documents can also be found in the `Symfony Repository`_. | ||
|
||
.. _`Symfony Repository`: https://github.com/symfony/symfony | ||
.. _`UPGRADE-2.7.md`: https://github.com/symfony/symfony/blob/2.7/UPGRADE-2.7.md |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
.. index:: | ||
single: Upgrading; Patch Version | ||
|
||
Upgrading a Patch Version (e.g. 2.6.0 to 2.6.1) | ||
=============================================== | ||
|
||
When a new patch version is released (only the last number changed), it is a | ||
release that only contains bug fixes. This means that upgrading to a new patch | ||
version is *really* easy: | ||
|
||
.. code-block:: bash | ||
|
||
$ composer update symfony/symfony | ||
|
||
That's it! You should not encounter any backwards-compatibility breaks or | ||
need to change anything else in your code. That's because when you started | ||
your project, your ``composer.json`` included Symfony using a constraint | ||
like ``2.6.*``, where only the *last* version number will change when you | ||
update. | ||
|
||
.. tip:: | ||
|
||
It is recommended to update to a new patch version as soon as possible, as | ||
important bugs and security leaks may be fixed in these new releases. | ||
|
||
.. include:: /cookbook/upgrade/_update_all_packages.rst.inc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will the toctree look nice on symfony.com? Probably it's better to use a list here for which we know for sure that they have nice styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Never mind, I guess the text above is only here to have some contents on the page that was used before, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is an example of a toctree: http://symfony.com/doc/current/cookbook/security/index.html
And indeed, the text above was just taken from the old article.