PHPackages                             thedava/dod-lite - 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. thedava/dod-lite

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

thedava/dod-lite
================

Document-oriented Database Lite - A simple file based document-oriented pseudo database

v0.1.3(9mo ago)03581GPL-3.0-or-laterPHPPHP ^8.1CI passing

Since Dec 25Pushed 9mo ago1 watchersCompare

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

READMEChangelog (10)Dependencies (1)Versions (13)Used By (1)

Document-oriented Database Lite
===============================

[](#document-oriented-database-lite)

[![.github/workflows/tests.yml](https://github.com/thedava/dod-lite/actions/workflows/tests.yml/badge.svg)](https://github.com/thedava/dod-lite/actions/workflows/tests.yml)

A simple file based document-oriented pseudo database.

**This library is still in alpha phase! Use at own risk!**

The main goal was to have a library that kind of combines the functionality of SQLite and a document-oriented database like MongoDB: Store data simply in a file without the need of a separate running database.

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

[](#installation)

via Composer

```
composer require thedava/dod-lite
```

Usage
-----

[](#usage)

The core component of DodLite is the DocumentManager. It is used to manage collections and provides some utility functionality like moving Documents between collections. The full documentation of the DocumentManager and an explanation of the basic concepts of DodLite can be found [here](docs/03-Concepts.md).

For an easy start, you can use the `DocumentManagerFactory` to create a new DocumentManager instance (without deep diving into the adapters). The Factory provides multiple methods to create a DocumentManager instance for different use cases. See the [Adapters](docs/04-Adapters.md) documentation for more information.

```
# \DodLite\DocumentManagerFactory methods
public static function createLocalFile(string $folderPath): DocumentManager
public static function createCachedLocalFile(string $folderPath): DocumentManager
public static function createIndexedLocalFile(string $folderPath): DocumentManager
public static function createIndexCachedLocalFile(string $folderPath): DocumentManager
```

```
// Create a new DocumentManager
$documentManager = \DodLite\DocumentManagerFactory::createLocalFile('/tmp');

// Get/Create collection "docs"
$collection = $documentManager->getCollection('docs');
```

### Writing data

[](#writing-data)

```
// Create a new document
$document = $collection->createDocument('README', [
    'file' => 'README.md',
    'headline' => 'Document-oriented Database Lite',
    'description' => 'A simple file based document-oriented pseudo database.',
]);

// Persist document
$collection->writeDocument($document);

// Create another document and persist it immediately
$document = $collection->createDocument('Exceptions', [
    'file' => '05-Exceptions.md',
    'headline' => 'Exceptions',
    'description' => 'DodLite employs a consistent error handling system',
], write: true);

// Write data directly without a document
$collection->writeData('Adapters', [
    'file' => '04-Adapters.md',
    'headline' => 'Adapters',
    'description' => 'DodLite uses adapters to store data',
]);

// Create a document manually and persist it
$document = new \DodLite\Documents\Document('Concepts', [
    'file' => '03-Concepts.md',
    'headline' => 'Concepts',
    'description' => 'Basic principles',
]);
$collection->writeDocument($document);
```

### Updating data

[](#updating-data)

```
// Retrieve document
$document = $collection->getDocument('Concepts');

// Update content manually
$content = $document->getContent();
$content['description'] = 'DodLite uses collections and documents to store data';
$document->setContent($content);

// Update content via helper method (array_replace_recursive)
$document->updateContent([
    'headline' => 'Concepts and Basic principles',
]);

// Persist document
$collection->writeDocument($document);
```

### Reading data

[](#reading-data)

```
// Get document
$document = $collection->getDocument('Adapters');
var_dump($document->getContent()); // { 'file' => '04-Adapters.md', ... }

// Get the first document that matches a filter
$document = $collection->getDocumentByFilter(
    new \DodLite\Filter\CallbackFilter(fn(Document $document) => $document->getContent()['file'] === '05-Exceptions.md')
);

// Get all documents
$documents = $collection->getAllDocuments();
foreach ($documents as $id => $document) {
    var_dump($document->getContent());
}

// Get all documents filtered
$documents = $collection->getAllDocumentsByFilter(
    new \DodLite\Filter\CallbackFilter(fn(Document $document) => str_ends_with($document->getContent()['file'], '.md'))
);
foreach ($documents as $id => $document) {
    var_dump($document->getContent());
}
```

### Check if data exists

[](#check-if-data-exists)

```
// Check if README exists
var_dump($collection->hasDocumentById('README')); // true
```

### Deleting data

[](#deleting-data)

```
// Delete document directly by id
$collection->deleteDocumentById('Adapters');

// Delete a document object
$document = $collection->getDocument('Exceptions');
$collection->deleteDocument($document);
```

Adapters
--------

[](#adapters)

DodLite uses adapters for storing data. Adapters are responsible for reading and writing data. They also provide additional functionality that is built on top of other adapters. For a full list of adapters see the [Adapters](docs/04-Adapters.md) documentation.

Error Handling
--------------

[](#error-handling)

Every error that is thrown in DodLite is either a `\DodLite\DodException` or a derivative of it. For a full explanation of all exceptions see the [Exceptions](docs/05-Exceptions.md) documentation.

Extensions
----------

[](#extensions)

- [dod-lite-flysystem](https://github.com/thedava/dod-lite-flysystem) - Flysystem adapter for DodLite

Docs
----

[](#docs)

- [Concepts](docs/03-Concepts.md)
- [Adapters](docs/04-Adapters.md)
- [Exceptions](docs/05-Exceptions.md)
- [Utilities](docs/06-Utils.md)

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance58

Moderate activity, may be stable

Popularity16

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity48

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 ~54 days

Recently: every ~97 days

Total

12

Last Release

270d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dfe307ab25846f0469a054ef44e01f27b9a73db67bf952acb47bf26d0e01caff?d=identicon)[dava](/maintainers/dava)

---

Top Contributors

[![thedava](https://avatars.githubusercontent.com/u/7238710?v=4)](https://github.com/thedava "thedava (52 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/thedava-dod-lite/health.svg)

```
[![Health](https://phpackages.com/badges/thedava-dod-lite/health.svg)](https://phpackages.com/packages/thedava-dod-lite)
```

###  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)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

PHPackages © 2026

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