|
| 1 | +.. _php-upgrade: |
| 2 | + |
| 3 | +======================== |
| 4 | +Upgrade Library Versions |
| 5 | +======================== |
| 6 | + |
| 7 | +.. contents:: On this page |
| 8 | + :local: |
| 9 | + :backlinks: none |
| 10 | + :depth: 1 |
| 11 | + :class: singlecol |
| 12 | + |
| 13 | +.. facet:: |
| 14 | + :name: genre |
| 15 | + :values: reference |
| 16 | + |
| 17 | +.. meta:: |
| 18 | + :keywords: compatibility, backwards compatibility |
| 19 | + :description: Learn how to upgrade the MongoDB PHP Library and PHP extension, ensuring compatibility and addressing breaking changes. |
| 20 | + |
| 21 | +Overview |
| 22 | +-------- |
| 23 | + |
| 24 | +In this guide, you can learn about the changes you must make to your application |
| 25 | +when you upgrade to a new version of the {+php-library+}. This page also describes |
| 26 | +how to upgrade your {+extension-short+} to a new version. |
| 27 | + |
| 28 | +How to Upgrade |
| 29 | +-------------- |
| 30 | + |
| 31 | +Before you upgrade, perform the following actions: |
| 32 | + |
| 33 | +- Ensure the new {+library-short+} version is compatible with the {+mdb-server+} versions |
| 34 | + your application connects to and the PHP version your |
| 35 | + application compiles with. For version compatibility information, see the |
| 36 | + :ref:`{+php-library+} Compatibility <php-compatibility>` |
| 37 | + page. |
| 38 | +- Address any breaking changes between the library version |
| 39 | + your application is using and your planned upgrade version in the |
| 40 | + :ref:`Breaking Changes <php-breaking-changes>` section. |
| 41 | + |
| 42 | +.. tip:: |
| 43 | + |
| 44 | + To ensure compatibility across {+mdb-server+} versions when |
| 45 | + upgrading library versions, use the :ref:`{+stable-api+} <php-stable-api>`. |
| 46 | + |
| 47 | +Major and minor versions of the PHP extension and library are in sync. This |
| 48 | +means you can run an upgrade command for the extension to also upgrade the PHP |
| 49 | +library. |
| 50 | + |
| 51 | +Patch versions (x.x.x) for the library and extension are not in sync. Run the |
| 52 | +respective commands to update to the patch versions for the library or extension. |
| 53 | + |
| 54 | +To upgrade the PHP extension, replace ``<version-number>`` with the version number |
| 55 | +you want to upgrade to and run the following command in your application's |
| 56 | +directory: |
| 57 | + |
| 58 | +.. code-block:: bash |
| 59 | + |
| 60 | + pecl upgrade mongodb-<version-number> |
| 61 | + |
| 62 | +To upgrade the PHP library version, replace ``<version-number>`` with the |
| 63 | +version number you want to upgrade to and run the following command in your |
| 64 | +application's directory: |
| 65 | + |
| 66 | +.. code-block:: bash |
| 67 | + |
| 68 | + composer require mongodb/mongodb:<version-number> |
| 69 | + |
| 70 | +Detailed installation instructions may be found in the |
| 71 | +:php:`PHP.net documentation <mongodb.installation>`. |
| 72 | + |
| 73 | +.. _php-breaking-changes: |
| 74 | + |
| 75 | +Breaking Changes |
| 76 | +---------------- |
| 77 | + |
| 78 | +A breaking change is a change of a convention or a behavior starting in |
| 79 | +a specific version of the library. This type of change may prevent your |
| 80 | +application from working properly if not addressed before upgrading the |
| 81 | +library. |
| 82 | + |
| 83 | +The breaking changes in this section are categorized by the library |
| 84 | +version that introduced them. When upgrading library versions, address |
| 85 | +all the breaking changes between the current and upgrade versions. |
| 86 | + |
| 87 | +For more information on release changes, see the release notes and |
| 88 | +associated JIRA tickets for each release on `GitHub |
| 89 | +<https://github.com/mongodb/mongo-php-library/releases>`__. |
| 90 | + |
| 91 | +.. _php-v2-breaking-changes: |
| 92 | + |
| 93 | +Version 2.0 Breaking Changes |
| 94 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 95 | + |
| 96 | +This library version introduces the following breaking changes: |
| 97 | + |
| 98 | +- The following methods return ``void`` instead of the raw command |
| 99 | + response: |
| 100 | + |
| 101 | + - ``MongoDB\\Client``: ``dropDatabase()`` |
| 102 | + - ``MongoDB\\Collection``: ``drop()``, ``dropIndex()``, |
| 103 | + ``dropIndexes()``, ``dropSearchIndex()``, ``rename()`` |
| 104 | + - ``MongoDB\\Database``: ``createCollection()``, ``drop()``, |
| 105 | + ``dropCollection()``, ``renameCollection()`` |
| 106 | + |
| 107 | + The ``MongoDB\\Database::createEncryptedCollection()`` method returns |
| 108 | + the list of encrypted fields instead of the raw command response. |
| 109 | + |
| 110 | + If there is an error, the methods throw an exception. |
| 111 | + |
| 112 | + If you must access the raw command response from the preceding |
| 113 | + methods, you can register a :php:`CommandSubscriber |
| 114 | + <mongodb-driver-monitoring-commandsubscriber>` in your application. |
| 115 | + |
| 116 | +Version 1.20 Breaking Changes |
| 117 | +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 118 | + |
| 119 | +This library version introduces the following breaking changes: |
| 120 | + |
| 121 | +- Drops support for {+mdb-server+} 3.6. |
| 122 | + |
| 123 | +Version 1.19 and Earlier |
| 124 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 125 | + |
| 126 | +For library versions 1.19 and earlier, see the release notes and associated |
| 127 | +JIRA tickets for each release on `GitHub <https://github.com/mongodb/mongo-php-library/releases>`__. |
0 commit comments