2.0.0
·
14 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
QueryandManagerclasses. - The
getServer()method and internalManagerreferences have been removed from APM event classes to streamline event data structures. - The
CursorIdclass has been removed;Cursor::getId()now returns anInt64directly. - Support for passing
WriteConcernandReadPreferenceobjects directly to execute methods has been removed in favor of usingreadPreferenceandwriteConcernoptions. - Legacy exceptions such as
WriteExceptionandSSLConnectionExceptionhave been removed.
Stronger Typing and Safer APIs
- The
UTCDateTimeconstructor no longer accepts strings or floats. It now only accepts integer millisecond timestamps or instances ofDateTimeInterface. WriteResultgetters will now throw exceptions when called on unacknowledged writes, making error states more explicit.- The
ReadPreferenceclass now requires string mode constants in its constructor. Support for legacy integer constants has been removed.
Deprecation and Legacy Cleanup
- The
Serializableinterface 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
Documentclass 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
CursorInterfacenow extends PHP’s nativeIteratorinterface.UTCDateTimeInterfaceintroduces a newtoDateTimeImmutable()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/mongodbComposer 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.0Or update an existing installation with:
pecl upgrade mongodb-2.0.0Windows binaries are attached to the GitHub release notes.