The Doctrine MongoDB project is an abstraction layer on top of the legacy PHP driver that the Doctrine MongoDB ODM project is built on top of.
This project has been deprecated and the MongoDB ODM project will soon no longer depend on it. The project is also in bug-fixes-only mode.
Creating new connections is easy using the
use Doctrine\MongoDB\Connection; $connection = new Connection('mongodb://localhost');
With the connection you can start selecting databases using the
$database = $connection->selectDatabase('my_project_database');
Now you are ready to select a collection and insert some data using the
$users = $database->selectCollection('users'); $user = [ 'username' => 'jwage', ]; $users->insert($user);
Reading data is easy using the
$user = $users->findOne(['username' => 'jwage']);
Updating a record is simple using the
$users->update(['username' => 'jwage'], ['$set' => ['isActive' => true]]);
Delete data from the collection using the
$collection->remove(['username' => 'jwage']);