MongoDB PHP library

Overview

MongoDB PHP Library

Tests Coding Standards

This library provides a high-level abstraction around the lower-level PHP driver (mongodb extension).

While the extension provides a limited API for executing commands, queries, and write operations, this library implements an API similar to that of the legacy PHP driver. It contains abstractions for client, database, and collection objects, and provides methods for CRUD operations and common commands (e.g. index and collection management).

If you are developing an application with MongoDB, you should consider using this library, or another high-level abstraction, instead of the extension alone.

Additional information about the architecture of this library and the mongodb extension may be found in Architecture Overview.

Documentation

Installation

The preferred method of installing this library is with Composer by running the following from your project root:

$ composer require mongodb/mongodb

Additional installation instructions may be found in the library documentation.

Since this library is a high-level abstraction for the driver, it also requires that the mongodb extension be installed:

$ pecl install mongodb
$ echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

Additional installation instructions for the extension may be found in its PHP.net documentation.

Reporting Issues

Issues pertaining to the library should be reported in the PHPLIB project in MongoDB's JIRA. Extension-related issues should be reported in the PHPC project.

For general questions and support requests, please use one of MongoDB's Technical Support channels.

Security Vulnerabilities

If you've identified a security vulnerability in a driver or any other MongoDB project, please report it according to the instructions in Create a Vulnerability Report.

Development

Development is tracked in the PHPLIB project in MongoDB's JIRA. Documentation for contributing to this project may be found in CONTRIBUTING.md.

Comments
  • php7 + opcache + mongodb: Query and php array is getting changed randomly.

    php7 + opcache + mongodb: Query and php array is getting changed randomly.

    We found some strange behaviour where queries sent to mongodb don't match what we intended to send.

    After digging deeper we found that under load with multiple requests handeled concurrently by php-fpm, the system randomly starts changing the php array (!). This only happens when the array is sent to the mongodb find operation (other operations not tested).

    We have only seen it changing the array when it has been sent to mongodb. Not calling ->find() does not produce the error.

    Also opcache need to be enabled for the file where the query array is defined. With opcache disabled it will not fail.

    The array is changed in a way that 'static' contents seem to be removed. We don't know if any more is getting replaced or changed. For example the part '[10, 12]' is replaced with NULL in our test case. Replacing one value with dynamic content eliminates the error too: repalce for example 12 with (int)$_GET['id'], call the test script with parameter test.php?id=10 and it will NOT fail.

    When using json_decode(json_encode($test), true) before submitting the data to ->find it will NOT fail and not change any contents of $test.

    The database and selection does not exist in our test case.

    We have tested with ext-mongodb 1.1.8 mongodb/mongodb 1.0.2 PHP 7.0.8-4

    Below the test script, run with apache benchmark

    
    require __DIR__ . '/../vendor/autoload.php';
    
    $test = ['test' => ['$in' => [10, 12]]];
    
    $client = new MongoDB\Client();
    $client->selectCollection('a','b')->find($test);
    
    file_put_contents('/tmp/mongodb-errors.log', (int)(serialize($test) == 'a:1:{s:4:"test";a:1:{s:3:"$in";a:2:{i:0;i:10;i:1;i:12;}}}'), FILE_APPEND);
    

    Run ab test: (optional) > sudo service php-fpm restart;

    ab -c 40 -n 1000 http://your.domain.goes.here/test.php

    Example result: 1 = success, array not changed, 0 = error, array has been changed. '[10, 12]' has been nulled.

    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
    11111111111111111111111111111111111111111111111111111111111111111111111111111111111111000000000000000000000000000000000000
    00000000000000000000000100000000000000000000000000000000000000000000000000111111111111111111111111111111111111111111111111
    11100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000
    00000000000000000000000000000000000111111111111111000000000000000000000000000000000000000000000000000000000000000000000000
    000000000000000000000000000000000000000000000000000000000000000000000000001111111```
    
    opened by cb-msales 44
  • MongoClient vs MongoDB backward compatibility issues

    MongoClient vs MongoDB backward compatibility issues

    Hello.

    I tried migrate from MongoClient to MongoDB and that was quite hard. Issues I'll found:

    1. MongoDB\Collection has no method to set read preference, we cant use constructor instead because of our private factory. Old MongoClient had setReadPreference, can you return it?
    2. MongoDB\Collection has no "limit" method like old MongoClient does, can you return it?
    3. findOne(['_id' => $id]) call returns item without "_id" property, it is empty (null). Can you fix it?
    opened by dmifedorenko 31
  • Aggregation Framework isDead true

    Aggregation Framework isDead true

    Hi Guys,

    I had an aggregation pipeline which worked in the old Mongo driver. I saw that there is no change between the 2 drivers, however the pipeline is not returning data.

    The 'match' stage includes MongoRegex which I've changed to 'MongoDB\BSON\Regex' and MongoDate in unix timestamp which I've change to MongoDB\BSON\UTCDateTime in milliseconds.

    2 question:

    1. Does MongoDB\BSON\UTCDateTime needs to get time in milliseconds or can I send it php unix timestamp which is in seconds? I think it is currently only working with milliseconds.
    2. The most important one: Why does it my pipeline is not working. The same pipeline works in the old driver. BTW, When the result is returned I always see isDead=true.

    I really need your help guys.

    opened by Roycohen 27
  • Invalid response_to for query, RuntimeException

    Invalid response_to for query, RuntimeException

    PHP Fatal error: Uncaught exception 'MongoDB\\Driver\\Exception\\RuntimeException' with message 'Invalid response_to for query. Expected 18989, got 18988.'

    mongodb 1.2.5
    mongodb/mongodb 1.1.1 MongoDB driver library
    

    This exception is occasional. Any solution? Thanks!

    opened by keita1314 21
  • Cant connect to mongodb Atlas with mongodb php module 1.4.4

    Cant connect to mongodb Atlas with mongodb php module 1.4.4

    Hello, I am trying to connect to mongoDB Atlas free tier from my linux shared hosted server which is running the mongodb php module 1.4.4 but I get an error.

    My code is the following:

    $manager = new MongoDB\Driver\Manager("mongodb://admin:[email protected]:27017,mongo-shard-00-01-waf4c.mongodb.net:27017,mongo-shard-00-02-waf4c.mongodb.net:27017/test?ssl=true&replicaSet=mongo-shard-0&authSource=admin&retryWrites=true");
    
    $bulk = new MongoDB\Driver\BulkWrite;
    
    $bulk->insert(['x' => 1]);
    $bulk->insert(['x' => 2]);
    $bulk->insert(['x' => 3]);
    $manager->executeBulkWrite('db.collection2', $bulk);
    

    The error I get is the following:

    Fatal error: Uncaught MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [connection closed calling ismaster on 'mongo-shard-00-00-waf4c.mongodb.net:27017'] [connection closed calling ismaster on 'mongo-shard-00-01-waf4c.mongodb.net:27017'] [connection closed calling ismaster on 'mongo-shard-00-02-waf4c.mongodb.net:27017'] in /test-connection.php:25 Stack trace: #0 /test-connection.php(25) MongoDB\Driver\Manager->executeBulkWrite('db.collection2', Object(MongoDB\Driver\BulkWrite)) #1 {main} thrown in /test-connection.php on line 25
    

    I dont get this error while running the same code on my local mamp configuration (1.5.1 php module) but the majority of hosting providers all have 1.4.4.

    (ive edited the credentials to not be publicly live with dummy hosts)

    question 
    opened by thenoblenewbie 19
  • No suitable servers found,connection closed calling ismaster on

    No suitable servers found,connection closed calling ismaster on

    err_no:13053 err_msg:No suitable servers found (serverSelectionTryOnce set): [connection closed calling ismaster on '10.9.10.6:27017']

    php run on 10.9.10.2 mongodb/mongodb version: 1.1.2,required by composer

    question 
    opened by ms100 17
  • $options['limit'] breaking find() query.

    $options['limit'] breaking find() query.

    This one has me baffled. We've spent about 6 hours today trying to understand what we're doing wrong when using limit.

    The following code works and returns 4 documents. For this particularly find there are only 4 documents that would ever match:

    $filter = [
        'cancel_reason' => null,
        'financial_status' => ['$ne' => 'pending'],
        'tags' => new MongoDB\BSON\Regex("kiosk", 'i'),
        'created_at' => ['$gte' => '2016-03-01T03:00:00-04:00', '$lte' => '2016-04-01T02:59:59-04:00'],
        '$or' => [
            [
            'tags' => new MongoDB\BSON\Regex("Fort Belvoir VA", 'i')
            ]
        ]
    ];
    
    $options['skip'] = 0;
    $options['limit'] = 4;
    
    $cursor = $collection->find($filter, $options);
    

    If I change limit to 3 like below, no documents are returned the script hangs and then dies with zero php errors and no exceptions being thrown:

    $options['limit'] = 3;

    bug 
    opened by Zelfapp 17
  • Connection timeout parameter being ignored?

    Connection timeout parameter being ignored?

    I've recently upgraded from the old MongoClient API to the latest version. It seems the new API ignores connection timeout requests.

    To test, I've intentionally added an incorrect hostname and set these three values to 1000 ms:

    • socketTimeoutMS
    • wTimeoutMS
    • connectTimeoutMS

    Sample code:

    $start = microtime(true);
    
    // Initialize connection string with timeouts
    $manager = new MongoDB\Driver\Manager('mongodb://user:pass@host:port/db?socketTimeoutMS=1000&wTimeoutMS=1000&connectTimeoutMS=1000');
    echo 'Created manager: ' . number_format(microtime(true) - $start, 6) . "\n";
    
    // Attempt to insert something since the manager connection is lazy
    $bulk      = new MongoDB\Driver\BulkWrite();
    $toInsert  = $bulk->insert(['hi' => 'there']);
    
    try
    {
        echo 'Created bulk write: ' . number_format(microtime(true) - $start, 6) . "\n";
        $rsp = $manager->executeBulkWrite('mydatabase.MyCollection', $bulk);
    
        // We'll get here if no exception is thrown
        echo 'Finished bulk write successfully: ' . number_format(microtime(true) - $start, 6);
    }
    catch (Exception $e)
    {
        // Print time it took to get here and the exception type/message
        echo 'Exception thrown from executeBulkWrite: ' . number_format(microtime(true) - $start, 6) . "\n";
        echo get_class($e) . ':' . $e->getMessage();
    }
    

    Output:

    Created manager: 0.000043
    Created bulk write: 0.000058
    Exception thrown from executeBulkWrite: 10.027685
    MongoDB\\Driver\\Exception\\ConnectionTimeoutException:No suitable servers found (`serverselectiontryonce` set): [Failed connecting to 'example.com:00000': php_network_getaddresses: getaddrinfo failed: Name or service not known]
    

    Why does the timeout always take 10 seconds to complete, regardless of what I put for the the timeout commands?

    FWIW, I've also tried this format:

    $opts = ['socketTimeoutMS' => 1000, 'wTimeoutMS' => 1000, 'connectTimeoutMS' => 1000];
    $manager = new MongoDB\Driver\Manager('mongodb://user:pass@host:port/db', $opts);
    
    bug 
    opened by zachrattner 17
  • Sharded cluster connection string with invalid hosts causes impossible connection

    Sharded cluster connection string with invalid hosts causes impossible connection

    Bug Report

    When using a list of mongos processes in the connection string, connection fails if the first host is not available instead of failing over to other hosts.

    Environment

    PHP 7.4 in docker container Mongodb 4.4.1 sharded cluster (5 nodes, each a complete PSS replica-set) with 8+ mongos processes.

    libbson bundled version => 1.17.0 libmongoc bundled version => 1.17.0 libmongoc SSL => enabled libmongoc SSL library => OpenSSL libmongoc crypto => enabled libmongoc crypto library => libcrypto libmongoc crypto system profile => disabled libmongoc SASL => enabled libmongoc ICU => disabled libmongoc compression => enabled libmongoc compression snappy => disabled libmongoc compression zlib => enabled libmongoc compression zstd => disabled libmongocrypt bundled version => 1.0.4 libmongocrypt crypto => enabled libmongocrypt crypto library => libcrypto mongodb.debug => no value => no value

    Composer: name : mongodb/mongodb descrip. : MongoDB driver library keywords : database, driver, mongodb, persistence versions : * 1.7.0

    Test Script

    Initiate a client like that:

    $client = new \MongoDB\Client("host1:33001,host2:33001,host3:33001");

    Expected and Actual Behavior

    The expected behavior, as described here is that if ever any of the hosts is down, it should try to connect to other ones. But it's not.

    Instead, the connection fails as soon as we try a read with an error like that if host2 and host3 are down / unreachable (and host1 is OK) :

    MongoDB\Driver\Exception\ConnectionTimeoutException: No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on 'host2:33001'] [connection refused calling ismaster on 'host3:33001']
    #0 /apps/vendor/api/mongodb/mongodb/src/functions.php(431): MongoDB\Driver\Manager->selectServer(Object(MongoDB\Driver\ReadPreference))
    #1 /apps/vendor/api/mongodb/mongodb/src/Collection.php(684): MongoDB\select_server(Object(MongoDB\Driver\Manager), Array)
    

    When trying with the mongo shell with this command, it works and connects to the mongos correctly:

    > mongo mongodb://host1:33001,host2:33001,host3:33001
    MongoDB shell version v4.4.1
    connecting to: mongodb://host1:33011,host2:33001,host3:33001/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("f55b5dad-32cd-44d6-9a0a-09ac00e9e0e4") }
    MongoDB server version: 4.4.1
    mongos>
    

    I lookup at the serverSelectionTryOnce connection setting, but it does work and the documentation says: Multi-threaded drivers and mongos do not support serverSelectionTryOnce.

    Can you please advise on that matter ? For now, I must explicitly specify only 1 mongos and this is a real issue.

    waiting-for-user tracked-in-jira 
    opened by H-Max 16
  • What is the alternative for Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Cursor::hasNext?

    What is the alternative for Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Cursor::hasNext?

    What is the alternative for Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Cursor::hasNext?

    One of my application using MongoDB Client library with old php version. I just upgraded my php version as well as upgraded mongo library. When following function is calling, it's giving me

    Fatal error: Uncaught Error: Call to undefined method MongoDB\Driver\Cursor::hasNext

    `function get_result_row () {

        if ($this->cursor->hasNext()) {
            return $this->cursor->getNext();
        }
    

    }`

    Please suggest how i can fix it?

    opened by ziyaindia 15
  • Can't connect to Atlas - Error:No suitable servers found

    Can't connect to Atlas - Error:No suitable servers found

    I'm having trouble connecting to Atlas as well with PHP. Connect fine using other libs and MongoChef so whitelisting is not the issue.

    • Windows 10
    • PHP 5.6.29
    • mongodb.dll ext 1.2.2
    • "mongodb/mongodb": "^1.1.0" from composer
    • Atlas cluster running MongoDB 3.2
    Error fetching Mongo. DB:myDB Coll:myCollection Error:No suitable servers found (`serverSelectionTryOnce` set): 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster on 'myShard.mongodb.net:27017'] 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster on 'myShard.mongodb.net:27017'] 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_serve query:{"theField":"theValue"} fields:{"projection":{"_id":1,"theField":1}}
    exception 'MongoDB\Driver\Exception\ConnectionTimeoutException' with message 'No suitable servers found (`serverSelectionTryOnce` set): 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster on 'myShard.mongodb.net:27017'] 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed calling ismaster on 'myShard.mongodb.net:27017'] 
    [TLS handshake failed: error:14090086:SSL routines:ssl3_get_serve' in C:\theapp\vendor\mongodb\mongodb\src\Collection.php:498
    Stack trace:
    #0 C:\theapp\vendor\mongodb\mongodb\src\Collection.php(498): MongoDB\Driver\Manager->selectServer(Object(MongoDB\Driver\ReadPreference))
    #1 C:\theapp\MyMongoClass.php(143): MongoDB\Collection->find(Array, Array)
    

    The sanitized url:

    mongodb://theUser:[email protected]:27017,myShard.mongodb.net:27017,myShard.mongodb.net:27017/admin?ssl=true&replicaSet=myReplicaset&authSource=admin
    

    Posted as suggested

    opened by Jeff-Lewis 15
  • Decision about `mongo-orchestration` folder and `Makefile`

    Decision about `mongo-orchestration` folder and `Makefile`

    Raised by @jmikola in https://github.com/mongodb/mongo-php-library/pull/1020:

    • [ ] Remove the mongo-orchestration folder?
    • [ ] Remove Makefile?

    If we found a decision, I am open to create PRs 👍

    cc @alcaeus

    opened by OskarStark 1
  • Can we drop `jean85/pretty-package-versions:1.2`?

    Can we drop `jean85/pretty-package-versions:1.2`?

    Is there a reason, we support two major versions? https://github.com/mongodb/mongo-php-library/blob/49f3e3dcadd8d8014f011d308116bdd3d96ad350/composer.json#L16

    IMHO 1.2 can safely be dropped, as 2.0 still supports PHP 7.1: https://github.com/Jean85/pretty-package-versions/blob/ea175e0a262389d59d35802d9e32319fa64449c0/composer.json#L5-L6

    opened by OskarStark 3
  • [BLOCKED] PHPLIB-1033 and PHPLIB-1042: Sync spec tests for retryable handshake errors

    [BLOCKED] PHPLIB-1033 and PHPLIB-1042: Sync spec tests for retryable handshake errors

    https://jira.mongodb.org/browse/PHPLIB-1033 https://jira.mongodb.org/browse/PHPLIB-1042

    Also adds a replica set w/ auth to the Evergreen matrix, which is needed to run some of the synced tests.

    Patch build: https://spruce.mongodb.com/version/6389522157e85a1fff7d0c01/tasks

    opened by jmikola 1
Releases(1.15.0)
  • 1.15.0(Nov 23, 2022)

    The PHP team is happy to announce that version 1.15.0 of the MongoDB PHP library is now available. Note that version 1.14.0 has been intentionally skipped to restore version parity between the library and extension.

    Release Highlights

    New examples/ and tools/ directories have been added to library repository, which contain code snippets and scripts that may prove useful when writing or debugging applications, respectively. These directories are intended to supplement the library's existing documentation, and will be added to over time.

    Various backwards compatible typing improvements have been made throughout the library. Downstream impact for these changes are discussed in UPGRADE-1.15.md. Additionally, Psalm has been integrated for static analysis going forward.

    This release upgrades the mongodb extension requirement to 1.15.0.

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

    Documentation

    Documentation for this library may be found in the PHP Library Manual.

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb:1.15.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.13.1(Sep 9, 2022)

    The PHP team is happy to announce that version 1.13.1 of the MongoDB PHP library is now available.

    Release Highlights

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb:1.13.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.13.0(Jul 16, 2022)

    The PHP team is happy to announce that version 1.13.0 of the MongoDB PHP library is now available. This release introduces support for MongoDB 6.0 and Queryable Encryption.

    Release Highlights

    MongoDB\Database::createCollection, MongoDB\Database::dropCollection, and MongoDB\Collection::drop now support an encryptedFields option. This is used by the library to manage internal collections used for queryable encryption.

    Helper methods for find, findAndModify, delete, and update commands now support a let option, which can be used to define variables that can be accessed within query filters and updates. Additionally, all helpers now support a comment option of any type (previously a string comment was only supported for queries).

    Change Streams with Document Pre- and Post-Images are now supported. Change stream watch() helpers now accept "whenAvailable" and "required" for the fullDocument option and support a new fullDocumentBeforeChange option, which accepts "whenAvailable" and "required". Change events may now include a fullDocumentBeforeChange response field. Additionally, MongoDB\Database::createCollection() and MongoDB\Database::modifyCollection() now support a changeStreamPreAndPostImages option to enable this feature on collections. Lastly, change stream watch() helpers now accept a showExpandedEvents option to enable the server to return additional events for DDL operations (e.g. creating indexes and collections) in the change stream.

    MongoDB\Database::createCollection() now supports creating clustered indexes and views. Clustered indexes were introduced in MongoDB 5.3. Views date back to MongoDB 3.4 but the corresponding options for the create command were never added to the library's helper method.

    MongoDB\Collection::estimatedDocumentCount() has been changed to always use the count command. In a previous release (1.9.0), the method was changed to use aggregate with a $collStats stage instead of the count command, which did not work on views. Reverting estimatedDocumentCount() to always use the count command addresses the incompatibility with views. Due to an oversight, the count command was omitted from the Stable API in server versions 5.0.0–5.0.8 and 5.1.0–5.3.1. Users of the Stable API with estimatedDocumentCount are advised to upgrade their MongoDB clusters to 5.0.9+ or 5.3.2+ (if on Atlas) or disable strict mode when using MongoDB\Driver\ServerApi.

    This release upgrades the mongodb extension requirement to 1.14.0.

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

    Documentation

    Documentation for this library may be found in the PHP Library Manual.

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb:1.13.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.13.0-beta1(Jun 8, 2022)

    The PHP team is happy to announce that version 1.13.0-beta1 of the MongoDB PHP library is now available. This release introduces support for MongoDB 6.0 and Queryable Encryption.

    Release Highlights

    MongoDB\Database::createCollection, MongoDB\Database::dropCollection, and MongoDB\Collection::drop now support an encryptedFields option. This is used by the library to manage internal collections used for queryable encryption.

    Helper methods for find, findAndModify, delete, and update commands now support a let option, which can be used to define variables that can be accessed within query filters and updates. Additionally, all helpers now support a comment option of any type (previously a string comment was only supported for queries).

    Change Streams with Document Pre- and Post-Images are now supported. Change stream watch() helpers now accept "whenAvailable" and "required" for the fullDocument option and support a new fullDocumentBeforeChange option, which accepts "whenAvailable" and "required". Change events may now include a fullDocumentBeforeChange response field. Additionally, MongoDB\Database::createCollection() and MongoDB\Database::modifyCollection() now support a changeStreamPreAndPostImages option to enable this feature on collections.

    MongoDB\Database::createCollection() now supports creating clustered indexes and views. Clustered indexes were introduced in MongoDB 5.3. Views date back to MongoDB 3.4 but the corresponding options for the create command were never added to the library's helper method.

    MongoDB\Collection::estimatedDocumentCount() has been changed to always use the count command. In a previous release (1.9.0), the method was changed to use aggregate with a $collStats stage instead of the count command, which did not work on views. Reverting estimatedDocumentCount() to always use the count command addresses the incompatibility with views. Due to an oversight, the count command was omitted from the Stable API in server versions 5.0.0–5.0.8 and 5.1.0–5.3.1. Users of the Stable API with estimatedDocumentCount are advised to upgrade their MongoDB clusters to 5.0.9+ or 5.3.2+ (if on Atlas) or disable strict mode when using MongoDB\Driver\ServerApi.

    This release upgrades the mongodb extension requirement to 1.14.0-beta1.

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

    Documentation

    Documentation for this library may be found at: https://www.mongodb.com/docs/php-library/current/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb:1.13.0-beta1@dev
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.12.0(Mar 23, 2022)

    The PHP team is happy to announce that version 1.12.0 of the MongoDB PHP library is now available.

    Release Highlights

    MongoDB\Database::listCollections() now supports an authorizedCollections option, which is supported by MongoDB 4.0 and later.

    The MongoDB\Collection::mapReduce() method has been deprecated. This corresponds to the deprecation of the mapReduce command in MongoDB 5.0. Users currently relying on mapReduce are encouraged to migrate to using the aggregation framework (see: Map-Reduce to Aggregation Pipeline).

    This release upgrades the mongodb extension requirement to 1.13.0. Support for MongoDB 3.4 and earlier has been removed.

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

    Documentation

    Documentation for this library may be found at: https://www.mongodb.com/docs/php-library/current/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb^1.12.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.11.0(Dec 15, 2021)

    The PHP team is happy to announce that version 1.11.0 of the MongoDB PHP library is now available.

    Release Highlights

    This release is compatible with PHP 8.1.0. Several deprecation notices have been addressed.

    GridFS stream operations will now throw the underlying exception instead of converting it to a PHP warning, as was done in previous versions of the library.

    This release upgrades the mongodb extension requirement to 1.12.0. Support for PHP 7.1 has been removed and the library now requires PHP 7.2 or newer.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb^1.11.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks to our community contributors for 1.11.0:

    Source code(tar.gz)
    Source code(zip)
  • 1.10.1(Dec 7, 2021)

    The PHP team is happy to announce that version 1.10.1 of the MongoDB PHP library is now available.

    Release Highlights

    This release changes the server selection logic for Database::aggregate() and Collection::aggregate() when the pipeline contains $out or $merge. The 1.10.0 release added support for executing these pipelines on 5.0+ secondaries, but introduced a bug that could cause a server selection failure in a mixed version replica set. With this change, a secondary will only be eligible if all servers in the topology are 5.0+; otherwise, the library will fall back to selecting a primary server.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb^1.10.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.10.0(Oct 29, 2021)

    The PHP team is happy to announce that version 1.10.0 of the MongoDB PHP library is now available. This release adds support for new features in MongoDB 5.0.

    Release Highlights

    Database::aggregate() and Collection::aggregate() now support executing $out and $merge pipelines on 5.0+ secondaries and will no longer force a primary read preference. If a pre-5.0 secondary would be selected, aggregate() will fall back to selecting a primary server.

    New Database::renameCollection() and Collection::rename() methods were introduced, which abstract the renameCollection command.

    This release upgrades the mongodb extension requirement to 1.11.0.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb^1.10.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks to our community contributors for 1.10.0:

    Source code(tar.gz)
    Source code(zip)
  • 1.9.0(Jul 13, 2021)

    The PHP team is happy to announce that version 1.9.0 of the MongoDB PHP library is now available. This release adds support for new features in MongoDB 5.0.

    Release Highlights

    The aggregate() methods now support a let option. A document may be specified to define variables that will then be accessible within the pipeline. This feature requires MongoDB 5.0 and is described in more detail in the aggregate command reference.

    Database::createCollection() supports creation of time series collections using new timeseries and expireAfterSeconds options. This feature requires MongoDB 5.0 and is described in more detail in the create command reference.

    The CollectionInfo class returned by Database::listCollections() has several new methods to improve access to the server's result objects: getInfo(), getType(), and getIdIndex(). Additionally, the getCappedMax(), getCappedSize(), and isCapped() methods have been deprecated.

    This release upgrades the mongodb extension requirement to 1.10.0. Support for PHP 7.0 has been removed and the library now requires PHP 7.1 or newer.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb^1.9.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks for our community contributors for 1.9.0:

    Source code(tar.gz)
    Source code(zip)
  • 1.9.0-alpha1(Apr 9, 2021)

    The PHP team is happy to announce that the first alpha release of version 1.9.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release adds support for Stable API (which will be released with MongoDB 5.0) and using Azure and GCP keystrokes for client-side field level encryption.

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

    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.9.0@alpha
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.8.0(Nov 25, 2020)

    The PHP team is happy to announce that version 1.8.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release makes the library compatible with PHP 8.

    With this release, errors that occur while copying GridFS stream contents will now cause an exception instead of relying on PHP to emit a warning. This primarily affects the downloadToStream, downloadToStreamByName, and uploadFromStream methods for MongoDB\GridFS\Bucket.

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

    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.8.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.8.0-RC1(Nov 10, 2020)

    The PHP team is happy to announce that the first release candidate of version 1.8.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release makes the library compatible with PHP 8.

    With this release, errors that occur while copying GridFS stream contents will now cause an exception instead of relying on a PHP Warning being emitted.

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

    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.8.0-RC1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.2(Nov 5, 2020)

    The PHP team is happy to announce that version 1.7.2 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release removes an unnecessary field from createIndexes commands.

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

    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.7.2
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.1(Oct 6, 2020)

    The PHP team is happy to announce that version 1.7.1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release fixes errors during PHP shutdown if GridFS streams were left open in a dirty state.

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

    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.7.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.0(Jul 31, 2020)

    The PHP team is happy to announce that version 1.7.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension. This release adds support for new features in MongoDB 4.4.

    Release Highlights

    New Client::listDatabaseNames and Database::listCollectionNames() methods allow enumeration of database and collection names without returning additional metadata. In the case of collection enumeration, this leverages the nameOnly option for listCollections and avoids taking a collection-level lock on the server.

    Client::listDatabases() now supports an authorizedDatabases option, which can be used with MongoDB 4.0.5 or newer.

    The Collection::deleteOne(), deleteMany(), and findOneAndDelete() methods now support a hint option to specify an index that should be used for the query. This option is also supported for delete operations in bulk writes. This option requires MongoDB 4.4 or later.

    The Collection::findOneAndReplace() and findOneAndUpdate() methods now support a hint option, which requires MongoDB 4.2.

    Collection::createIndex() and createIndexes() now support a commitQuorum option, which can be used with MongoDB 4.4.

    The MongoDB\Operation\Aggregate class now implements the MongoDB\Operation\Explainable interface and can be used with Collection::explain(). This is an alternative to the explain option supported by Collection::aggregate() and allows for more verbose output when explaining aggregation pipelines.

    The Client constructor now supports a driver option in its $driverOptions parameter, which can be used by wrapping drivers and libraries to append metadata (e.g. name and version) to the server handshake. The PHP library will also now append its own name and version to the metadata reported by the mongodb extension. Note that this feature is primarily designed for custom drivers and ODMs, which may want to identify themselves to the server for diagnostic purposes. Applications should use the appName URI option instead of driver metadata.

    This release upgrades the mongodb extension requirement to 1.8.0. Support for PHP 5.6 has been removed and the library now requires PHP 7.0 or newer.

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

    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.7.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.0-rc1(Jul 17, 2020)

    The PHP team is happy to announce that version 1.7.0-rc1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    New MongoDB\Client::listDatabaseNames and MongoDB\Database::listCollectionNames methods allow enumeration of database and collection names without returning additional metadata. In the case of collection enumeration, this leverages the nameOnly option for listCollections and avoids taking a collection-level lock on the server.

    The MongoDB\Operation\Aggregate class now implements the MongoDB\Operation\Explainable interface and can be used with MongoDB\Collection::explain(). This is an alternative to the explain option supported by MongoDB\Collection::aggregate() and allows for more verbose output when explaining aggregation pipelines.

    As previously announced, this version drops compatibility with PHP 5.6 and requires PHP 7.0 or newer.

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

    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.7.0@RC
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.6.1(Jul 8, 2020)

    The PHP team is happy to announce that version 1.6.1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release fixes a bug where the Database::command() helper incorrectly inherited a read preference from the database.

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

    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.6.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.0-beta2(Jun 10, 2020)

    The PHP team is happy to announce that version 1.7.0-beta2 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This beta release provides support for additional new features in MongoDB 4.4 following the previous 1.7.0-beta1 release.

    Collection::createIndex() and createIndexes() now support a commitQuorum option, which can be used with MongoDB 4.4.

    Client::listDatabases() now supports an authorizedDatabases option, which can be used with MongoDB 4.0.5 or newer.

    As previously announced, this version drops compatibility with PHP 5.6 and requires PHP 7.0 or newer.

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

    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.7.0@beta
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.7.0-beta1(Apr 14, 2020)

    The PHP team is happy to announce that version 1.7.0-beta1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This beta release provides support for new features in MongoDB 4.4.

    For authentication, this release adds support for the new MONGODB-AWS authentication mechanism. The SCRAM mechanism now supports shorter conversation when authenticating with the server.

    The delete command (and its helpers), delete operations in bulk writes, as well as all findAndModify operations now support specifying a hint option.

    As previously announced, this version drops compatibility with PHP 5.6, limiting support to PHP 7.0 and newer.

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

    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.7.0@beta
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.6.0(Feb 4, 2020)

    The PHP team is happy to announce that version 1.6.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release introduces classes and options to enable Client-Side Field Level Encryption. With this feature, sensitive data can be automatically encrypted (MongoDB Enterprise Edition only) or explicitly encrypted using the MongoDB\Driver\ClientEncryption API.

    The MongoDB\Collection::updateOne, updateMany, replaceOne methods now support a hint option to specify the index that should be used for the query. The option is also supported for update operations in bulk writes. This option requires MongoDB 4.2 or later.

    This release deprecates using a JavaScript instance with scope when calling MongoDB\Collection::mapReduce for the map, reduce, and finalize options. Use the scope option instead. The nonAtomic and sharded options for the $out Map-Reduce argument are also deprecated.

    Please note that this is the last minor release series that is compatible with PHP 5. Support for PHP 5 will be dropped in the upcoming 1.7.0 release.

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

    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.6.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.2(Jan 13, 2020)

    The PHP team is happy to announce that version 1.5.2 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release fixes a potential memory leak when using the MongoDB\Model\CachingIterator class and tightens validation around the chunkSizeBytes option for GridFS file uploads.

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

    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.5.2
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.1(Oct 29, 2019)

    The PHP team is happy to announce that version 1.5.1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release fixes passing an aggregation pipeline to update operations in a bulk write. The distinct helper in MongoDB\Collection now also correctly inherits the collection's type map when it wasn't passed using the $options argument.

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

    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.5.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.5.0(Sep 9, 2019)

    The PHP team is happy to announce that version 1.5.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension. This release adds support for new features in MongoDB 4.2.

    Release Highlights

    Together with version 1.6.0 of the mongodb extension, this release allows running multi-document transactions on sharded clusters when connected to MongoDB 4.2.

    To make working with transactions easier, this release introduces a new, more convenient API for executing transactions. The new MongoDB\with_transaction() function takes a MongoDB\Driver\Session argument and a callback that will be run within a transaction for the given session. The function itself handles starting and committing the transaction, as well as handling any retryable errors that occur during the process.

    Change stream iterators now provide a MongoDB\ChangeStream::getResumeToken() method, which allows retrieving a token that can be used to resume the change stream after the current position. This token can be used with the resumeAfter option, as well as the new startAfter option introduced in MongoDB 4.2. The latter allows resuming a change stream after an "invalidate" event, such as dropping or renaming a collection.

    Update methods (e.g. updateMany(), findOneAndUpdate()) now support passing an aggregation pipeline for the update argument. This allows for more complex atomic updates than before. See Update with an Aggregation Pipeline in the MongoDB manual for more information on this new feature.

    This release adds compatibility with PHP 7.4 and drops support for PHP 5.5.

    This release upgrades the mongodb extension requirement to 1.6.0.

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

    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.5.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks for our community contributors for this release:

    Source code(tar.gz)
    Source code(zip)
  • 1.4.3(Jul 16, 2019)

    The PHP team is happy to announce that version 1.4.3 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release addresses two bugs related to resuming a change stream during its iteration. The iteration key reported by the change stream is now properly incremented for an iteration event that resumes. Additionally, the resume token is now correctly updated on consecutive resume attempts.

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

    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.4.3
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.4.2(Jul 30, 2018)

    The PHP team is happy to announce that version 1.4.2 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This releases addresses a bug where MongoDB\Collection::countDocuments() would throw an exception if no documents are found. Some tests were improved too.

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

    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.4.2
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.4.1(Jul 10, 2018)

    The PHP team is happy to announce that version 1.4.1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release contains a fix for cloning MongoDB\Model\BSONArray and MongoDB\Model\BSONDocument objects that contain uncloneable PHP objects.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb=^1.4.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.4.0(Jun 27, 2018)

    The PHP team is happy to announce that version 1.4.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension. This release adds support for new features in MongoDB 4.0 and drops support for MongoDB 2.6 and earlier.

    Release Highlights

    MongoDB 4.0 introduces support for cluster-level and database-level change streams, which may be created via the new MongoDB\Client::watch() and MongoDB\Database::watch() methods, respectively. All change streams now support a startAtOperationTime option, which can be used to specify an exact point in time for the change stream to begin. Additionally, the internal logic for resuming change streams after encountering an error has been improved.

    New MongoDB\Collection::countDocuments() and MongoDB\Collection::estimatedDocumentCount() methods have been introduced. countDocuments() may be executed within a transaction and should be preferred where an exact document count is required. estimatedDocumentCount() cannot be executed within a transaction but may otherwise be used when an approximate, non-filtered count is acceptable. The MongoDB\Collection::count() has been deprecated (in documentation only) due to its incompatibility with transactions and inaccuracy in sharded clusters. Users should note that countDocuments() uses an aggregation pipeline instead of the count command, so it does not support $where, $near, and $nearSphere query operators accepted in a count() filter (alternative syntax is discussed in the countDocuments() documentation).

    A MongoDB\Collection::explain() method has been introduced as a helper for the explain command, which may be used to explain operations such as find, findAndModify, update, and others. MongoDB\Collection::aggregate() now also supports an explain option (note: the server's API for explaining aggregate differs from other commands).

    Several usability improvements were made for the library's model classes for database, collection, and index information. Additionally, a MongoDB\Database::modifyCollection() method has been introduced as a wrapper for the collMod command.

    This release upgrades the mongodb extension requirement to 1.5.0. Support for MongoDB 2.6 and earlier has been removed.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb=^1.4.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.3.2(Apr 19, 2018)

    The PHP team is happy to announce that version 1.3.2 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release contains fixes for session consistency in change streams and executing findAndModify commands when a client-level read concern has been specified.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb=^1.3.2
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Source code(tar.gz)
    Source code(zip)
  • 1.3.1(Mar 27, 2018)

    The PHP team is happy to announce that version 1.3.1 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension.

    Release Highlights

    This release contains fixes for key incrementing in ChangeStream::next() and resume functionality in ChangeStream::rewind(). Additionally, it includes a performance improvement for seeking forward in GridFS files.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb=^1.3.1
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks for our community contributors for this release:

    Source code(tar.gz)
    Source code(zip)
  • 1.3.0(Feb 9, 2018)

    The PHP team is happy to announce that version 1.3.0 of the MongoDB PHP library is now available. This library is a high-level abstraction for the mongodb extension. This release adds support for new features in MongoDB 3.6 and drops support for MongoDB 2.4 and earlier.

    Release Highlights

    Version 1.4.0 of the mongodb extension introduced a new MongoDB\Driver\Session class to support client sessions for MongoDB 3.6. Session objects may be created via a new MongoDB\Client::startSession() method. All Client, Database, and Collection methods that communicate with the server now accept a "session" option. Presently, this option may be used for facilitating causally consistent reads. Sessions are not currently supported for GridFS operations.

    MongoDB 3.6 introduced change streams, which allows applications to subscribe to all data changes on a collection (without manually tailing the oplog). Change streams are implemented using the aggregation framework and tailable cursors. This release adds support for change streams via a new MongoDB\Collection::watch() method, which returns a MongoDB\ChangeStream iterator. This iterator wraps a MongoDB\Driver\Cursor object and implements additional functionality, such as automatic resuming in the event of a dropped connection. A new tutorial on tailable cursor iteration has been added to the documentation, which is relevant for anyone working with tailable cursors or change streams.

    Update methods (e.g. updateMany(), findOneAndUpdate()) now support an arrayFilters option, which may be used to specify which elements to modify in an array field. See Specify arrayFilters for Array Update Operations in the MongoDB manual for more information on this new feature.

    MongoDB\Client::listDatabases() now supports a filter option, which may be used to filter which databases are returned when connected to MongoDB 3.6.

    This release upgrades the mongodb extension requirement to 1.4.0. Support for MongoDB 2.4 and earlier has been removed.

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

    Documentation

    Documentation for this library may be found at: https://docs.mongodb.com/php-library/

    Installation

    This library may be installed or upgraded with:

    composer require mongodb/mongodb=^1.3.0
    

    Installation instructions for the mongodb extension may be found in the PHP.net documentation.

    Thanks

    Thanks for our community contributors for this release:

    Source code(tar.gz)
    Source code(zip)
Psalm Stubs for doctrine/mongodb-odm library

doctrine-mongodb-psalm-plugin A Doctrine plugin for Psalm (requires Psalm v4). Installation: $ composer require --dev runtothefather/doctrine-mongodb-

Evgeny 6 Jun 15, 2022
Simple MongoDB API for PHP!

SimpleMongo SimpleMongo is a simple API for MongoDB, written in PHP. How to use? First of all, copy SimpleMongo.php into your project and fill the fir

AlicanCopur 9 Jul 19, 2021
RockMongo is a MongoDB administration tool, written in PHP 5.

Introduction -------------------------------------- RockMongo is a MongoDB administration tool, written in PHP 5, very easy to install and use. Inst

Liu Xiangchao 1k Dec 27, 2022
A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

Laravel MongoDB This package adds functionalities to the Eloquent model and Query builder for MongoDB, using the original Laravel API. This library ex

Jens Segers 6.3k Jan 5, 2023
Eloquent MongoDB Repository Implementation

Eloquent MongoDB Repository Eloquent MongoDB Repository using nilportugues/repository as foundation, using jenssegers/mongodb. Installation Use Compos

Nil Portugués Calderó 18 Feb 12, 2022
MongoDB ORM that includes support for references,embed and multilevel inheritance.

Introduction Features Requirements Installation Setup Database Basic Usage - CRUD Relationship - Reference Relationship - Embed Collection Inheritance

Michael Gan 202 Nov 17, 2022
Migrations for MongoDB based on PHPMongo ODM

PHPMongo Migrator Migrations for MongoDB based on PHPMongo ODM Schema not required in MongoDb, so we dont need to create databases, collections or alt

Sokil 29 Jul 13, 2022
Extend Jenssegers/laravel-mongodb to support transaction function

Laravel Mongodb (Transactional support) Introduction Jensseger's laravel-mongodb extension package is very popular among Laravel developers, but it la

Iman RJ 10 Nov 1, 2022
A Php Library For MySQL

phpSQL MySql İçin Bir Php Kütüphanesi Herhangi Bir Sorun Olursa Buradan Ulaşabilirsiniz Ayrıca Dosyada Php Documentor Kullanılmaktadır, Modern Editörl

GamerboyTR 1 Oct 24, 2021
MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query and get result in a fastest way. ( WEBSITE VERSION )

Mysql Optimizer mysql optimizer also known as MOP is a php query handling and manipulation library providing easy and reliable way to manipulate query

null 3 Feb 14, 2022
A simple PHP library to transfer data from a source (object or array) to an object.

SimplexMapper A simple PHP library to transfer data from a source (object or array) to an object. $dbData = [ 'username' => 'pfazzi', 'emailAd

Patrick Luca Fazzi 4 Sep 22, 2022
Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Simple MySQL library for PHP 5.4+ includes Query Builder, PDO Native functions, Helper functions for quick use.

Kodols 9 Dec 22, 2022
A simple library for managing database connections, results pagination and building queries in PHP

PHP lions-software-database-manager This is a simple library for managing database connections, results pagination and building queries in PHP. Esta é

Lions Software 0 Feb 7, 2022
The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

The Enobrev\ORM library is a small framework of classes meant to be used for simply mapping a mysql database to PHP classes, and for creating simply SQL statements using those classes.

Mark Armendariz 0 Jan 7, 2022
A drop-in library for certain database functionality in Laravel, that allows for extra features that may never make it into the main project.

Eloquence Eloquence is a package to extend Laravel's base Eloquent models and functionality. It provides a number of utilities and classes to work wit

Kirk Bushell 470 Dec 8, 2022
This project is about import CSV to Laravel with Laravel Excel library.

About Laravel Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experie

Abraham Víctor Zaragoza Rodríguez 1 Nov 20, 2021
A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL.

grifart/tables A simple library to access and manipulate database records. Built on top of Dibi and hardwired for PostgreSQL. This library is develope

GRIFART 5 Nov 11, 2022
Just another PDO database library

PDO Just another PDO database library Installation Use Composer $ composer require faapz/pdo Usage Examples selecting, inserting, updating and deletin

Fabian de Laender 313 Oct 11, 2022
TO DO LIST WITH LOGIN AND SIGN UP and LOGOUT using PHP and MySQL please do edit the _dbconnect.php before viewing the website.

TO-DO-LIST-WITH-LOGIN-AND-SIGN-UP TO DO LIST WITH LOGIN AND SIGN UP and LOGOUT using PHP and MySQL please do edit the _dbconnect.php before viewing th

Aniket Singh 2 Sep 28, 2021