PHPackages                             bigtallbill/php-mongo-graph-model - 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. [Database &amp; ORM](/categories/database)
4. /
5. bigtallbill/php-mongo-graph-model

ActiveLibrary[Database &amp; ORM](/categories/database)

bigtallbill/php-mongo-graph-model
=================================

A data model for storing incremental data for graphs

1750PHP

Since Aug 25Pushed 10y ago2 watchersCompare

[ Source](https://github.com/bigtallbill/php-graph-data-manager)[ Packagist](https://packagist.org/packages/bigtallbill/php-mongo-graph-model)[ RSS](/packages/bigtallbill-php-mongo-graph-model/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

php-graph-data-manager
======================

[](#php-graph-data-manager)

A small library that helps store graph-type (incremental stats) in mongo database using doctrine ODM

Installation
============

[](#installation)

Add this to your composer.json

```
"require": {
    "bigtallbill/php-mongo-graph-model": "dev-master"
}

```

Usage
=====

[](#usage)

```

// instantiate a new instance providing the doctrine DocumentManager instance
$gm = new GraphManager($dm);

$gm->setGranularity(GraphManager::MINUTE);
$gm->setWindow(GraphManager::HOUR);

// create a random statistic to store. These are instances of ParsedStat
// and can be created manually if required
$stat = $gm->parseSimpleKeyValue('system_stats', 'cpu', rand(25, 50));

// finally run an upsert using doctrine to create or update the stat
$gm->insertStat($stat);

```

How this model looks
====================

[](#how-this-model-looks)

Using a granularity of Hours and a window of Days:

```
{
    "_id" : ObjectId("5560b3b7919124c4e03710fd"),
    "date" : ISODate("2015-05-23T00:00:00.000Z"),
    "granularity" : NumberLong(3600),
    "group" : "system_stats",
    "key" : "mem",
    "window" : NumberLong(86400),
    "window_human" : "Day",
    "granularity_human" : "Hour",
    "segments" : {
        "1432400400" : NumberLong(108588),
        "1432404000" : NumberLong(119624)
    }
}

```

Under the *segments* key is where each segment of granularity is stored (in our case the top of the current hour). The *date* is locked to the top of the current window (in our case the current day)

Here is another example with a granularity of minutes and a window of hours:

```
{
    "_id" : ObjectId("5560c023919124c4e0371102"),
    "date" : ISODate("2015-05-23T18:00:00.000Z"),
    "granularity" : NumberLong(60),
    "group" : "system_stats",
    "key" : "processes",
    "window" : NumberLong(3600),
    "window_human" : "Hour",
    "granularity_human" : "Minute",
    "segments" : {
        "1432404000" : NumberLong(59041),
        "1432404060" : NumberLong(41138),
        "1432404120" : NumberLong(62544),
        "1432404180" : NumberLong(59392),
        "1432404240" : NumberLong(22948),
        "1432404300" : NumberLong(58825),
        "1432404360" : NumberLong(31936),
        "1432404420" : NumberLong(17407),
        "1432404480" : NumberLong(30097),
        "1432404540" : NumberLong(54094),
        "1432404600" : NumberLong(34739),
        "1432404660" : NumberLong(34164),
        "1432404720" : NumberLong(34571),
        "1432404780" : NumberLong(28592)
    }
}

```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8caa9b48729c93df3849117fd3973e801748d871e786d53c7ff00c14c8563a43?d=identicon)[bigtallbill](/maintainers/bigtallbill)

---

Top Contributors

[![bigtallbill](https://avatars.githubusercontent.com/u/727370?v=4)](https://github.com/bigtallbill "bigtallbill (10 commits)")

### Embed Badge

![Health badge](/badges/bigtallbill-php-mongo-graph-model/health.svg)

```
[![Health](https://phpackages.com/badges/bigtallbill-php-mongo-graph-model/health.svg)](https://phpackages.com/packages/bigtallbill-php-mongo-graph-model)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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