Another way to connect, that works for me:
require 'vendor/autoload.php';//composer require "mongodb/mongodb=^1.0.0.0"
$m = new MongoDB\Client("mongodb://alex:mypassword@10.111.0.2:27017/");
echo "Connection to database successfull. <br>";