PHPackages                             gaillard/gridfs-update - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. gaillard/gridfs-update

ActiveLibrary

gaillard/gridfs-update
======================

Library to make mongo gridfs in-place updates

v1.0.0(11y ago)1284MITPHPPHP &gt;=5.4.0

Since Jul 29Pushed 11y ago1 watchersCompare

[ Source](https://github.com/gaillard/gridfs-update-php)[ Packagist](https://packagist.org/packages/gaillard/gridfs-update)[ RSS](/packages/gaillard-gridfs-update/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

gridfs-update-php
=================

[](#gridfs-update-php)

[![Build Status](https://camo.githubusercontent.com/205c056b526765ffd3b5532b17933068d50c8202a22504c2fabc20e9cf3cebd1/68747470733a2f2f7472617669732d63692e6f72672f6761696c6c6172642f6772696466732d7570646174652d7068702e706e67)](https://travis-ci.org/gaillard/gridfs-update-php)

Library to make mongo gridfs in-place updates

Requirements
------------

[](#requirements)

Requires PHP 5.4.0 (or later).

Installation
------------

[](#installation)

To add the library as a local, per-project dependency use [Composer](http://getcomposer.org)!

```
{
    "require": {
        "gaillard/gridfs-update": "~1.0"
    }
}
```

Example
-------

[](#example)

```
$id = new \MongoId();

$gridfs = (new \MongoClient())->selectDB('gridfsUpdaterExample')->getGridFS();
$gridfs->storeBytes('123456', ['_id' => $id, 'metadata' => ['key1' => 'Hello', 'key2' => 'Mr.', 'key3' => 'Smith']]);

$before = $gridfs->findOne();
echo 'metadata is ';
var_dump($before->file['metadata']);
echo "bytes are {$before->getBytes()}\n";

GridFsUpdater::update(
    $gridfs,
    $id,
    '7890',
    [
        '$set' => ['metadata.key2' => 'Bob'],
        '$unset' => ['metadata.key3' => ''],
    ]
);

$after = $gridfs->findOne();
echo 'metadata is now ';
var_dump($after->file['metadata']);
echo "bytes are now {$after->getBytes()}\n";
```

prints

```
metadata is array(3) {
  'key1' =>
  string(5) "Hello"
  'key2' =>
  string(3) "Mr."
  'key3' =>
  string(5) "Smith"
}
bytes are 123456
metadata is now array(2) {
  'key1' =>
  string(5) "Hello"
  'key2' =>
  string(3) "Bob"
}
bytes are now 7890
```

Which has updated the chunks without removing them (unless there are extra) and the file doc as well. Primary benefit is speed. Please be aware of any side effects in your system for concurrent access. The [mongo-lock-php](https://github.com/gaillard/mongo-lock-php) library could help!

Contributing
------------

[](#contributing)

If you would like to contribute, please use the build process for any changes and after the build passes, send a pull request on github!

```
./build.php
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4301d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9b08e5ccb3610f5099e7d82d7241203a40dab3503709e55373babb40fa7174c2?d=identicon)[gaillard](/maintainers/gaillard)

---

Tags

mongoGridFS

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/gaillard-gridfs-update/health.svg)

```
[![Health](https://phpackages.com/badges/gaillard-gridfs-update/health.svg)](https://phpackages.com/packages/gaillard-gridfs-update)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M70](/packages/mongodb-laravel-mongodb)[yiisoft/yii2-mongodb

MongoDB extension for the Yii framework

3312.1M43](/packages/yiisoft-yii2-mongodb)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M61](/packages/creocoder-yii2-flysystem)[desarrolla2/cache

Provides an cache interface for several adapters Apc, Apcu, File, Mongo, Memcache, Memcached, Mysql, Mongo, Redis is supported.

1322.5M47](/packages/desarrolla2-cache)[mmucklo/queue-bundle

Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}

120839.8k](/packages/mmucklo-queue-bundle)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
