The easy, powerful and ultrafast ODM for PHP and MongoDB.


With Mandango you will be able to store files in Mongo using GridFS through MongoGridFS objects of the PHP driver very easily.

For it you have to map them as files:

    'Model\Image' => array(
        'isFile' => true,
        'fields' => array(
            'name' => 'string',

When doing it the field file is automatically added, that is the one in which the file is saved:

$image = $mandango->create('Model\Image');

// as file

// as bytes


And to retrieve them it is done the same way:

$image = $imageRepository->createQuery()->one();

$image->getFile() // \MongoGridFSFile

$bytes = $image->getFile()->getBytes();

The file can't be updated. The remaining mapped field can be updated.

Fork me on GitHub