PHPackages                             tina4stack/tina4php-mongodb - 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. tina4stack/tina4php-mongodb

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

tina4stack/tina4php-mongodb
===========================

Tina4 PHP MongoDB Database Driver

v2.0.3(1mo ago)142MITPHPPHP &gt;=8.1CI failing

Since Dec 6Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/tina4stack/tina4php-mongodb)[ Packagist](https://packagist.org/packages/tina4stack/tina4php-mongodb)[ RSS](/packages/tina4stack-tina4php-mongodb/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (9)Versions (6)Used By (0)

tina4php-mongodb
================

[](#tina4php-mongodb)

MongoDB database driver for the Tina4 PHP framework. Works seamlessly with the Tina4 ORM — write standard SQL and the built-in NoSQL parser translates it to native MongoDB operations.

[![Tests](https://github.com/tina4stack/tina4php-mongodb/actions/workflows/tests.yml/badge.svg)](https://github.com/tina4stack/tina4php-mongodb/actions/workflows/tests.yml)

Installing
----------

[](#installing)

```
composer require tina4stack/tina4php-mongodb
```

### Requirements

[](#requirements)

- PHP &gt;= 8.1
- MongoDB PHP extension (`ext-mongodb`)
- MongoDB PHP library (`mongodb/mongodb`)

Usage
-----

[](#usage)

### Basic Connection

[](#basic-connection)

```
global $DBA;

// Local MongoDB
$DBA = new \Tina4\DataMongoDb("localhost/27017:myDatabase");

// With authentication
$DBA = new \Tina4\DataMongoDb("localhost/27017:myDatabase", "username", "password");
```

### With Tina4 ORM

[](#with-tina4-orm)

```
class User extends \Tina4\ORM
{
    public $tableName = "users";
    public $id;
    public $name;
    public $email;
}

// Create
$user = new User();
$user->name = "Andre";
$user->email = "andre@example.com";
$user->save();

// Read
$user = new User();
$user->load("name = 'Andre'");
echo $user->name;

// Update
$user->email = "new@example.com";
$user->save();
```

### Direct Queries

[](#direct-queries)

```
global $DBA;

// Insert
$DBA->exec("insert into users (name, email) values (?, ?)", "Andre", "andre@example.com");

// Select
$result = $DBA->fetch("select name, email from users where name = 'Andre'");

// Update
$DBA->exec("update users set email = 'new@example.com' where name = 'Andre'");

// Delete
$DBA->exec("delete from users where name = 'Andre'");
```

Docker (for testing)
--------------------

[](#docker-for-testing)

```
docker run -d --name tina4_mongo -p 27017:27017 mongo
```

Running Tests
-------------

[](#running-tests)

```
composer test
```

---

Our Sponsors
------------

[](#our-sponsors)

**Sponsored with 🩵 by Code Infinity**

[![Code Infinity](https://camo.githubusercontent.com/1516fb1662e3486bce77822177a5ea199edc32ea109369812592ec9bca38159a/68747470733a2f2f636f6465696e66696e6974792e636f2e7a612f77702d636f6e74656e742f75706c6f6164732f323032352f30392f6338652d6c6f676f2d6769746875622e706e67)](https://codeinfinity.co.za/about-open-source-policy?utm_source=github&utm_medium=website&utm_campaign=opensource_campaign&utm_id=opensource)

*Supporting open source communities • Innovate • Code • Empower*

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~389 days

Total

5

Last Release

57d ago

Major Versions

v1.0.0 → v2.0.02022-03-15

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f5b9029a2a1d8a442e33ae01ba9ea43eada3c842edfa785a74304c7cd6ed0f9?d=identicon)[tina4stack](/maintainers/tina4stack)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tina4stack-tina4php-mongodb/health.svg)

```
[![Health](https://phpackages.com/badges/tina4stack-tina4php-mongodb/health.svg)](https://phpackages.com/packages/tina4stack-tina4php-mongodb)
```

###  Alternatives

[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[doctrine/mongodb-odm

PHP Doctrine MongoDB Object Document Mapper (ODM) provides transparent persistence for PHP objects to MongoDB.

1.1k23.3M302](/packages/doctrine-mongodb-odm)[alcaeus/mongo-php-adapter

Adapter to provide ext-mongo interface on top of mongo-php-library

46412.3M73](/packages/alcaeus-mongo-php-adapter)[moloquent/moloquent

A MongoDB based Eloquent model and Query builder for Laravel (Moloquent)

120114.6k7](/packages/moloquent-moloquent)[doesntmattr/mongodb-migrations

Managed Database Migrations for MongoDB

23598.7k1](/packages/doesntmattr-mongodb-migrations)[facile-it/mongodb-bundle

Bundle service integration of official \[mongodb/mongo-php-library\](https://github.com/mongodb/mongo-php-library) driver library

38212.1k1](/packages/facile-it-mongodb-bundle)

PHPackages © 2026

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