Skip to content

2.0.0

Latest
Compare
Choose a tag to compare
@mongodb-dbx-release-bot mongodb-dbx-release-bot released this 10 Apr 07:38
· 5 commits to v2.0 since this release

The PHP team is happy to announce that version 2.0.0 of the mongodb PHP extension is now available on PECL.

Release Highlights

This major release introduces a number of backwards-incompatible changes aimed at simplifying and modernizing the extension's API, cleaning up deprecated functionality, and improving type safety and runtime behavior.

API Cleanups and Removals

  • Deprecated constructor options have been removed from the Query and Manager classes.
  • The getServer() method and internal Manager references have been removed from APM event classes to streamline event data structures.
  • The CursorId class has been removed; Cursor::getId() now returns an Int64 directly.
  • Support for passing WriteConcern and ReadPreference objects directly to execute methods has been removed in favor of using readPreference and writeConcern options.
  • Legacy exceptions such as WriteException and SSLConnectionException have been removed.

Stronger Typing and Safer APIs

  • The UTCDateTime constructor no longer accepts strings or floats. It now only accepts integer millisecond timestamps or instances of DateTimeInterface.
  • WriteResult getters will now throw exceptions when called on unacknowledged writes, making error states more explicit.
  • The ReadPreference class now requires string mode constants in its constructor. Support for legacy integer constants has been removed.

Deprecation and Legacy Cleanup

  • The Serializable interface has been removed from BSON classes, following its deprecation in PHP 8.1.
  • All deprecated global BSON functions have been removed; users should use methods on the Document class instead.
  • Several configure options (--with-libbson, --with-libmongoc, --enable-system-ciphers, --with-openssl-dir) have been removed to simplify the build process.

New Features and Improvements

  • CursorInterface now extends PHP’s native Iterator interface.
  • UTCDateTimeInterface introduces a new toDateTimeImmutable() method.
  • URI options that expect booleans will now throw if a non-boolean value is provided, preventing silent misconfiguration.

Library Upgrades

  • The extension now bundles libmongoc 1.30.3, bringing in the latest stability and feature improvements.

Compatibility updates

  • This release requires an upgrade to the mongodb/mongodb Composer library, which introduces compatibility changes for this extension version. Be sure to update your Composer dependencies accordingly.
  • PHP 8.1+ Required: The minimum required PHP version is now 8.1, as support for older versions (PHP 7.4 and 8.0) has been dropped.
  • MongoDB 4.2+ Required: Future versions of the library will require MongoDB 4.2 or later. MongoDB 4.0 support is deprecated.

A complete list of resolved issues in this release may be found in JIRA.

Documentation

Documentation is available on PHP.net.

Installation

You can either download and install the source manually, or install the extension via PECL:

pecl install mongodb-2.0.0

Or update an existing installation with:

pecl upgrade mongodb-2.0.0

Windows binaries are attached to the GitHub release notes.