PHPackages                             punarinta/doru-db - 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. punarinta/doru-db

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

punarinta/doru-db
=================

A simple file-based database storing data in JSON.

v0.1.1(9y ago)018MITPHPPHP &gt;=7.0.0

Since Jan 29Pushed 7y ago2 watchersCompare

[ Source](https://github.com/punarinta/doru-db)[ Packagist](https://packagist.org/packages/punarinta/doru-db)[ RSS](/packages/punarinta-doru-db/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)DependenciesVersions (3)Used By (0)

DoruDB
======

[](#dorudb)

A simple file-based database. Stores data in JSON format. Supports basic CRUD operations and concurrency. The name comes from a Proto-Indo-European word 'doru' which meant 'a tree'. This database is one tool in a bigger collection with this name.

Usage
=====

[](#usage)

#### Connecting to the database

[](#connecting-to-the-database)

```
use \DoruDB\Database;

// if no arguments are passed to constructor the database is stored in 'db' folder
$db = new Database('path/to/db');
```

#### Inserting a record

[](#inserting-a-record)

```
$user = $db->create('user', ['name' => 'That Guy']);

// this will insert a document with a unique id and nothing else
$user = $db->create('user');

// this will also insert a record, as update() works as 'upsert' if ID is given
$user = $db->update('user', ['id' => 1337, 'name' => 'This Guy']);
```

#### Finding a record

[](#finding-a-record)

```
// this is the fastest way to fetch a document, but you need to have an ID
$user = $db->findById('user', 1337);

// 'find' returns one record
$users = $db->find('user', ['filter' => ['name' => 'This Guy']]);

// 'findAll' returns all. NB: filter can use user-defined functions
$users = $db->find('user', ['filter' => ['name' => function ($x)
{
    return strpos($x, 'Guy') !== false;
} ]]);
```

#### Limit/offset

[](#limitoffset)

```
$users = $db->findAll('user', ['offset' => 1, 'limit' => 1]);
```

Using limit/offset with filters on the fields that do not have indices is slower than just limit/offset or filters with indices, as the database has to read all documents first to apply limit and offset.

#### Sorting

[](#sorting)

Only sorting by ID is supported for now. Use 'invert' option to use descending sorting.

```
$users = $db->findAll('user', ['invert' => true]);
```

#### Removing a record

[](#removing-a-record)

```
// deletes one document
$db->delete('user', 1337);

// deletes all documents
$db->truncate('user');
```

#### Working with indices

[](#working-with-indices)

Index support is still experimental. Use with care. Indices are used to speed up filter, limit and offset operations.

```
// add an index or update it automatically
$db->rebuildIndex('user', 'lastLogin');

// update index manually with one or more documents
$db->updateIndex('user', 'lastLogin', $someDocument);

// remove index completely from the database
$db->removeIndex('user', 'lastLogin');
```

ToDo
====

[](#todo)

- make ID immutable
- unique indices
- improve index r/w performance
- sync index on document update
- counting with non-indexed filter

License
=======

[](#license)

This project is licensed under the terms of [**MIT**](https://github.com/punarinta/doru-db/blob/master/LICENSE) license.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

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.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

3391d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/754c799a3ccee283cb079e7753a87e1f876ffb97d846bb1664793681fb635d9f?d=identicon)[punarinta](/maintainers/punarinta)

---

Top Contributors

[![punarinta](https://avatars.githubusercontent.com/u/2189981?v=4)](https://github.com/punarinta "punarinta (62 commits)")

---

Tags

jsondatabasenosql

### Embed Badge

![Health badge](/badges/punarinta-doru-db/health.svg)

```
[![Health](https://phpackages.com/badges/punarinta-doru-db/health.svg)](https://phpackages.com/packages/punarinta-doru-db)
```

###  Alternatives

[cubettech/lacassa

Cassandra based query builder for laravel.

358.5k](/packages/cubettech-lacassa)[soosyze/queryflatfile

The Queryflatfile is PHP library for simple database not SQL

181.0k1](/packages/soosyze-queryflatfile)

PHPackages © 2026

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