At least two reasons why this problem occurs ( Client Error: Remaining data too small for BSON object ):
1. The MongoDB PHP driver is not compatible with MongoDB installed on the machine.
(originally mentioned in the first answer ).
Examine the version of the PHP driver installed on your computer at <?php phpinfo(); :

Extract the MongoDB version using:
mongod --version\ # db version v3.2.0
Use the compatibility table on the MongoDB website to find out if the version of the PHP driver MongoDB is compatible with the version of MongoDB:

If the versions are incompatible, you must remove one of the existing parts and install a compatible version. From my own experience, itβs much easier to change the PHP MongoDB driver, since only another .so extension file is required.
2. Two PHP MongoDB drivers are installed on the machine.
Since MongoClient deprecated, many tutorials and articles on the Internet (including the official mongo-php driver repository on Github ) now contain instructions for installing the mongodb driver, not mongo PHP. A year + earlier, everyone pointed to the mongo extension.
Due to this change from mongo to mongodb we can get both extensions defined in the php.ini . Just make sure that only one extension is defined in the "Dynamic Extension" section:

I hope someone gets this answer when looking for a solution to fix the error "The rest of the data is too small for the BSON object" working with MongoDB through PHP MongoDB.
source share