Question: I've got some problems with my Connection string. Seached the web for some mistakes but didn't got any further. Is there something changed between SQL Server versions?

```
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <configSections>
    </configSections>
    <connectionStrings>
        <add name="BeursTD.Properties.Settings.sdtcaptConnectionString"
            connectionString="Data Source=localhost\SQLEXPRESS,1433;Initial Catalog=sdtcapt;User ID=XXXX;Password=XXXX"
            providerName="System.Data.SqlClient" />
    </connectionStrings>
</configuration>

```

Answer: 
There are at least two reasons why this issue (`Client Error: Remaining data too small for BSON object`) appears:

**1. PHP MongoDB driver is not compatible with MongoDB installed on the machine.**  

(originally mentioned in the [first answer](https://stackoverflow.com/a/34646148/309031)). 

Examine PHP driver version set up on your machine on `<?php phpinfo();` page:

[![enter image description here](https://i.stack.imgur.com/oaB0u.jpg)](https://i.stack.imgur.com/oaB0u.jpg) 

Retrieve MongoDB version in use with:

```
mongod --version\
# db version v3.2.0

```

Use [compatibility table on MongoDB website](https://docs.mongodb.org/ecosystem/drivers/php/#compatibility) to see whether examined PHP MongoDB driver version is compatible with MongoDB version:

[![enter image description here](https://i.stack.imgur.com/8uMyC.jpg)](https://i.stack.imgur.com/8uMyC.jpg) 

If versions are not compatible, it is required to uninstall one of the existing parts and install compatible version. From my own experience, it is much easier to change PHP MongoDB driver, since only different `.so` extension file is required.

**2. Two PHP MongoDB drivers are installed on the machine.**

Since [`MongoClient`](http://php.net/manual/en/class.mongoclient.php) is deprecated, many tutorials and articles online (including [official mongo-php-driver repository on Github](https://github.com/mongodb/mongo-php-driver#installation)) now guides to install `mongodb`, not `mongo` PHP driver. Year+ before, everyone was pointing at `mongo` extension, however.

Because of this change from `mongo` to `mongodb`, we might get both extensions defined in `php.ini` file. *Just make sure, only one extension is defined under "Dynamic Extension" section*:

[![enter image description here](https://i.stack.imgur.com/4lPG6.jpg)](https://i.stack.imgur.com/4lPG6.jpg)

---

Hope somebody gets this answer useful when looking for a solution to fix "Remaining data too small for BSON object" error working with MongoDB through PHP MongoDB driver.
The issue was that Laravel was unable to communicate with MongoDB because I was using the mongodb-1.1 php driver and MongoDB 3.2 together. According to the table found on this page: <https://docs.mongodb.org/ecosystem/drivers/php/>, these two versions are not compatible. I uninstalled MongoDB 3.2 and installed MongoDB 3.O, and the problem was solved.