Skip to content
Choose a tag to compare


@alcaeus alcaeus released this
· 16 commits to v1.6 since this release
Choose a tag to compare

The PHP team is happy to announce that version 1.6.0 of the mongodb PHP extension is now available on PECL. This release adds support for new features in MongoDB 4.2.

Release Highlights

This release adds support for multi-document transactions on sharded clusters. When starting a transaction on a sharded cluster, the first operation executed within the transaction will pin the session to a specific mongos server, ensuring that all subsequent operations in the transaction will be sent to the same server. This server is exposed via the new MongoDB\Driver\Session::getServer() method. The MongoDB\Driver\Session::isInTransaction() method exposes whether a transaction is currently in progress (i.e. started but not yet committed or aborted).

The MongoDB\Driver\Exception\RuntimeException class now exposes error labels via the hasErrorLabel() method. This can be used to infer certain error categories, such as transient failures in transactions, which indicate that the transaction can be retried and may succeed on a subsequent attempt.

When connected to MongoDB 3.6 or later, the driver can now automatically retry queries and read commands executed with executeQuery() and executeReadCommand(), respectively, that fail due to a network error or replica set failover. Note that only initial queries and commands can be retried; getMore commands issued during cursor iteration are not retryable. This feature is controlled by a new retryReads URI option, which defaults to true.

As of this release, retryable writes are now enabled by default. Note that retryable writes are fundamentally incompatible with the MMAPv1 storage engine. Applications still relying on MMAPv1 should consider upgrading to WiredTiger or otherwise disable retryable writes explicitly by setting the retryWrites URI option to false.

MongoDB 4.2 introduced aggregation pipelines for updates, which allows for more expressive update statements (e.g. conditional updates based on current field values). To support this feature, BulkWrite::update() now accepts a pipeline array as its second argument.

Starting with this release, TLS options may be passed using the tls* URI options in either the connection string or array options to MongoDB\Driver\Manager::construct(). The use of driver options (i.e. third constructor argument) is still supported. The ca_dir option, its deprecated alias capath, and the crl_file option are not supported as URI options and still need to be passed as driver options.

This release upgrades our libbson and libmongoc dependencies to 1.15.1. Support for PHP 5.5 has been removed. The extension now supports all PHP versions from 5.6 through 7.4.

A complete list of resolved issues in this release may be found at:


Documentation is available on


We would appreciate any feedback you might have on the project:


You can either download and install the source manually, or you can install the extension with:

pecl install mongodb

or update with:

pecl upgrade mongodb

Windows binaries are available on PECL: