Skip to content

1.0.0-beta2

Pre-release
Pre-release
Compare
Choose a tag to compare
@jmikola jmikola released this 28 Dec 20:20
· 1958 commits to master since this release

The PHP team is happy to announce that version 1.0.0-beta2 of our MongoDB PHP library, which abstracts our PHP and HHVM extensions, is now available. This release adds support for new features in MongoDB 3.2 and introduces a new option to control BSON unserialization throughout the library.

Release Highlights

The core Database and Collection classes are now constructed with options arrays instead of nullable WriteConcern and ReadPreference parameters. The new typeMap and readConcern options may now be passed in via these arrays. Additionally, both classes now have a withOptions() method to allow users to create a cloned instance with different options (e.g. changing the default read preference for a Collection).

A new Database::command() method was added to allow users to execute arbitrary database commands for which the library may not already provide a helper.

The new typeMap option, which was introduced to the Client, Database, and Collection classes, allows users to provide a default type map to be applied to cursors returned by the library. This option is inherited from parent contexts (i.e. a Client's type map will be inherited by selected Database and Collection objects). Users looking to emulate the legacy driver's behavior of returning both BSON documents and arrays as PHP arrays may use the following type map:

$client = new MongoDB\Client($uri, [], ['typeMap' => ['root' => 'array', 'document' => 'array']]);

The above behavior is not recommended due to ambiguities between associative and numerically indexed PHP arrays, which is why we abandoned this legacy behavior in the new driver. For our upcoming 1.0.0 stable release, we hope to provide user-friendly classes for BSON documents and arrays to use in the library's default type map. These classes will implement PHP's ArrayAccess interface (addressing concerns some users have working with stdClass instances) while still ensuring that documents and arrays are correctly serialized to BSON (using object-casting and array_values(), respectively). Progress for that task is being tracked in PHPLIB-74.

This release also has several internal improvements for compatibility with version 1.1.1 of the PHP "mongodb" extension, which added support for PHP 7.

A complete list of resolved issues in this release may be found at:
https://jira.mongodb.org/secure/ReleaseNote.jspa?projectId=12483&version=16400

Documentation

Documentation for this library (and its API) may be found at:
http://mongodb.github.io/mongo-php-library/

Feedback

If you encounter any bugs or issues with this library, please report them via this form:
https://jira.mongodb.org/secure/CreateIssue.jspa?pid=12483&issuetype=1

Installation

This library may be installed or upgraded with:

composer require "mongodb/mongodb=^1.0.0@beta"

The MongoDB PHP driver may be installed or upgraded with:

pecl install mongodb

Installation Instructions for the HHVM driver may be found in that project's README.

Thanks

Thanks for our community contributors for this release: