Skip to content

1.1.0-alpha1

Pre-release
Pre-release
Compare
Choose a tag to compare
@jmikola jmikola released this 29 Sep 16:22

The PHP team is happy to announce that version 1.1.0-alpha1 of our MongoDB PHP library is now available. This library is a high-level abstraction for the PHP 5, PHP 7, and HHVM drivers (i.e. mongodb extension).

Release Highlights

This release includes an implementation of the GridFS specification, which allows reading and writing of GridFS files using PHP's streams and filesystem functions. MongoDB\Database::selectGridFSBucket() may be used to instantiate a MongoDB\GridFS\Bucket object, which is analogous to MongoDB::getGridFS() and the MongoGridFS class in the legacy driver, respectively.

MongoDB\GridFS\Bucket provides the following methods for reading from GridFS files:

  • openDownloadStream(): Selects a file by _id and returns a readable stream.
  • openDownloadStreamByName(): Selects a file by filename (and optionally a revision) and returns a readable stream.
  • downloadToStream(): Selects a file by _id and copies its contents to the destination stream.
  • downloadToStreamByName(): Selects a file by filename (and optionally a revision) and copies its contents to the destination stream.

MongoDB\GridFS\Bucket provides the following methods for writing to GridFS files:

  • openUploadStream(): Returns a writable stream for a new GridFS file. A filename is required and you may optionally provide: _id (defaults to a new MongoDB\BSON\ObjectID), metadata (analogous to custom fs.files fields in the legacy driver), and chunkSizeBytes (defaults to 261120). After writing to the stream, you must close it (e.g. fclose()) to commit the file document to the GridFS collection.
  • uploadFromStream(): Creates a writable stream for a new GridFS file (given a filename and the same options as openUploadStream()) and copies the contents of a readable stream to the new GridFS file. The _id of the newly created GridFS file will be returned.

Additional utility and helper methods exist on the MongoDB\GridFS\Bucket class, which you will find documented in the source. API reference and a GridFS tutorial will be added to the library documentation closer to the final 1.1.0 release.

A couple of other enhancements have also made it into this release. A getManager() accessor method has been added to the MongoDB\Client, MongoDB\Database, and MongoDB\Collection classes, which may be used to retrieve the MongoDB\Driver\Manager extension object. The MongoDB\Model\BSONDocument and MongoDB\Model\BSONArray classes now implement PHP's JsonSerializable interface. This will complement the driver's BSON types implementing the same interface in version 1.2.0 of extension (tracked in PHPC-459 and HHVM-158).

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

Documentation

Documentation for this library may be found at:
https://docs.mongodb.com/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.1.0-alpha1

Installation instructions for the PHP and HHVM driver may be found in the PHP.net documentation.

Thanks

Thanks for our community contributors for this release: