MongoDB GridFS PHP how to read an example?

In the official documentation of MongoDB GridFS says that in order to successfully work with GridFS, you can use MongoDB\Driver\Manager or owned by the MongoDB PHP Library class MongoDB\Database (or rather his method selectGridFSBucket()). My question concerns the example of how it works. Help to understand what's going on in the next line:

$bucket = (new MongoDB\Client)->example->selectGridFSBucket();

PS There's a view that is created by the Manager and through him to access a database example. But how with this sintaksa treatment is not clear. Not much documentation clarifies this point, like how you can open the stream with MongoDB\Driver\Manager. Apparently this is quite obvious.
August 19th 19 at 23:22
1 answer
August 19th 19 at 23:24
The team can be divided into parts to make it easier to understand.

The object is connect to the database (MongoDB\Client)
$connection = new MongoDB\Client;

The object is MongoDB\Database to work with a specific database. It uses the magic method __get, the documentation says:
Selects a database on the server. This magic method is an alias for the selectDatabase() method.

That is, the following commands do the same thing.
$database = $connection->example;
$database = $connection->selectDatabase("example");

Well, now we get the object MongoDB\GridFS\Bucket for file storage in database $database
$bucket = $database->selectGridFSBucket();

Perhaps I somehow not so understood, what your problem is - so ask additional questions in the comments
The problem was how to understand this example, as is also the crank using only Mongo Driver(extention). Answer the question fully I think is right, so say it. - nona_Bergna commented on August 19th 19 at 23:27

Find more questions by tags MongoDBPHP