PHPackages                             dirtyscript/flatdb - 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. dirtyscript/flatdb

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

dirtyscript/flatdb
==================

Flat file simple key-value DataBase

0.03.000(9y ago)445MITPHPPHP &gt;=5.3.2

Since Jul 20Pushed 9y ago4 watchersCompare

[ Source](https://github.com/dirtyscript/flatdb)[ Packagist](https://packagist.org/packages/dirtyscript/flatdb)[ Docs](http://dirty-script.com/)[ RSS](/packages/dirtyscript-flatdb/feed)WikiDiscussions master Synced today

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

Dirty Script &gt; FlatDB
========================

[](#dirty-script--flatdb)

PHP flat file data base class.
based on simple key =&gt; value.
key can be a string, a date, a int ... value can be array, string, int ...

This system works well for small projects that do not require a large database.

need more test and improvements, so use it for fun/test/debug/small project...

```
/**
 * DSDB - Dirty Script Data Base
 *
 * a flat file basic data base
 * manage datas by key(id)
 *
 * PHP version 5.3
 *
 * @author     RemRem
 * @copyright  2014-2016
 * @licence    MIT
 * @link       http://dirty-script.com/Data-Base
 * @link       https://github.com/DirtyScript/FlatDB
 */
```

### install &amp; use with composer

[](#install--use-with-composer)

Using FlatDB with composer is quite easy. Just add DirtyScript\\FlatDB to your projects requirements.

```
require_once 'vendor/autoload.php';

use DirtyScript\FlatDB;
```

### init a db

[](#init-a-db)

db-name must be the full path to your database file don't need to put an extension

```
$your_db = new FlatDB( '/var/www/database/db-name' , true );
```

FlatDB will create `db-name.json.gz.php`make sure of `/var/www/database/` can be readable and writable.

### store a data

[](#store-a-data)

```
$your_db->data_push('you-key','This is your data');
```

return bool. by default data\_push() don't overwrite data if the key is already here, if you want overwrite the data, just add a 3rd option (true)

```
$your_db->data_push('key','datas',true);
```

make overwrite the data stored for 'key'

if you dont want to handle the key and let FlatDB handle it

```
$your_db->data_push(null,'datas');
```

### read a data

[](#read-a-data)

```
$your_data = $your_db->data_get('key');
```

you must provide the 'key'.

### get all keys

[](#get-all-keys)

```
$your_keys = $your_db->data_keys();
```

return an array with all the key stored

### remove a data

[](#remove-a-data)

```
$your_db->data_remove('key');
```

return bool

### reset the database

[](#reset-the-database)

```
$your_db->db_reset();
```

return bool

### reload the database / get all db content

[](#reload-the-database--get-all-db-content)

```
$your_db->db_read();
```

read the database file and return an array with all key =&gt; data stored

### get somes infos about the database

[](#get-somes-infos-about-the-database)

```
$your_db->db_infos();
```

return an array with some infos.

### export

[](#export)

```
$your_db->db_export( $format );
```

`$format` (string) can be csv, json, xml or serialize. Need more tests...

### backup

[](#backup)

```
$you_db->db_backup( $backup_name );
```

`$backup_name` (string) the name of the backup if `$backup_name` is empty, DSDB just add `-backup` in file name before extension. This function just make a copy of the database file.

### get the last insert

[](#get-the-last-insert)

```
$your_db->data_get_last_line( 3 );
```

get X last line(s)

### search in the data

[](#search-in-the-data)

```
$your_db->data_search( $test, $limit );
```

try to search for specific data need some work on this function, I will develop more soon

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity49

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

Every ~17 days

Total

2

Last Release

3614d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/497268?v=4)[RemRem](/maintainers/RemRem)[@remrem](https://github.com/remrem)

---

Tags

databaseflatfile

### Embed Badge

![Health badge](/badges/dirtyscript-flatdb/health.svg)

```
[![Health](https://phpackages.com/badges/dirtyscript-flatdb/health.svg)](https://phpackages.com/packages/dirtyscript-flatdb)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k595.8M6.5k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k295.3M7.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k249.9M3.9k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k212.9M508](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k141.0M563](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k47.9M443](/packages/robmorgan-phinx)

PHPackages © 2026

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