PHPackages                             robert-grubb/filerdb-php - 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. robert-grubb/filerdb-php

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

robert-grubb/filerdb-php
========================

FilerDB PHP Package

v2.0(2y ago)879[1 issues](https://github.com/RobertGrubb/filerdb-php/issues)2MITPHPPHP &gt;=5.4.0CI failing

Since May 30Pushed 2y ago3 watchersCompare

[ Source](https://github.com/RobertGrubb/filerdb-php)[ Packagist](https://packagist.org/packages/robert-grubb/filerdb-php)[ Docs](https://github.com/RobertGrubb/filerdb-php)[ RSS](/packages/robert-grubb-filerdb-php/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (6)Used By (2)

FilerDB
=======

[](#filerdb)

A simplistic PHP flat file database designed to get your application up and running fast. Please note this package is currently in development and is not yet at a release.

Usage
=====

[](#usage)

Install via composer:

`composer require robert-grubb/filerdb-php`

*NOTE*: Please make sure your database directory has correct permissions for READ and WRITE.

### Instantiating

[](#instantiating)

```
use FilerDB\Instance;

// Instantiate Database
$filerdb = new Instance([ 'root' => __DIR__ . '/database/' ]);

```

### Configuration

[](#configuration)

```
[

  /**
   * This is the root path for FilerDB.
   */
  'root' => false,

  /**
   * If the root path does not exist, try
   * and create it.
   */
  'createRootIfNotExist' => false,

  /**
   * If the database does not exist, try
   * and create it.
   */
  'createDatabaseIfNotExist' => false,

  /**
   * If the collection does not exist, attempt
   * to create it.
   */
  'createCollectionIfNotExist' => false,

  /**
   * If the insert and update logic handles
   * the createdAt and updatedAt timestamps
   * automatically
   */
  'includeTimestamps' => false

]

```

### Creating a database

[](#creating-a-database)

```
$filerdb->databases->create('dev');

```

### Check if database exists

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

```
$filerdb->databases->exists('dev'); // Returns true or false

```

### List all databases

[](#list-all-databases)

```
$filerdb->databases->list(); // Returns array

```

### Deleting a database

[](#deleting-a-database)

```
$filerdb->databases->delete('dev');

```

### Selecting a default database

[](#selecting-a-default-database)

Selecting a default database allows you to not have to specify the database on every call. Please refer to the below code on how to do that.

```
// Specify it in the configuration:
$filerdb = new Instance([
  'path' => __DIR__ . '/database/',
  'database' => 'database_name'
]);

```

or

```
$filerdb->selectDatabase('database_name');

```

With the above, you can now do the following:

```
$filerdb->collection('users')->all(); // Notice no ->database()

```

### List collections in a database

[](#list-collections-in-a-database)

```
$filerdb->database('dev')->collections(); // Returns array

```

### Check if collection exists

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

```
$filerdb->database('dev')->collectionExists('dev'); // Returns true of false

```

### Creating a collection

[](#creating-a-collection)

```
$filerdb->database('dev')->createCollection('users');

```

### Deleting a collection

[](#deleting-a-collection)

```
$filerdb->database('dev')->deleteCollection('users');

```

### Empty a collection

[](#empty-a-collection)

```
$filerdb->database('dev')->collection('users')->empty();

```

### Inserting a document

[](#inserting-a-document)

```
$filerdb->database('dev')->collection('users')->insert([
  'username' => 'test',
  'email'    => 'test@test.com'
]);

```

### Updating a document

[](#updating-a-document)

```

// By a specific document
$filerdb
  ->database('dev')
  ->collection('users')
  ->id('ad23tasdg')
  ->update([
    'username' => 'test2'
  ]);

// Where all usernames equal test
$filerdb
  ->database('dev')
  ->collection('users')
  ->filter(['username' => 'test'])
  ->update([
    'username' => 'test2'
  ]);

```

### Deleting a document

[](#deleting-a-document)

```
// Specific document
$filerdb
  ->database('dev')
  ->collection('users')
  ->id('asdfwegd')
  ->delete();

// With filters
$filerdb
  ->database('dev')
  ->collection('users')
  ->filter(['username' => 'test'])
  ->delete();

```

### Retrieving all documents

[](#retrieving-all-documents)

```
$filerdb->database('dev')->collection('users')->all()

```

### Retrieving document by id

[](#retrieving-document-by-id)

```
$filerdb
  ->database('dev')
  ->collection('users')
  ->id('asdf23g')
  ->get();

```

### Retrieving document by filters

[](#retrieving-document-by-filters)

```
// Get users with username of test and greater than age of 10.
$filerdb
  ->database('dev')
  ->collection('users')
  ->filter(['username' => 'test'])
  ->filter([ ['age', '>', '10'] ])
  ->get();

```

### Specify fields that come back in response

[](#specify-fields-that-come-back-in-response)

```
// Only returns the username field
$filerdb
  ->database('dev')
  ->collection('users')
  ->get(['username']);

```

### Ordering documents by a field

[](#ordering-documents-by-a-field)

```
// Get users with username of test and greater than age of 10.
$filerdb
  ->database('dev')
  ->collection('users')
  ->orderBy('username', 'asc')
  ->get();

```

### Limiting number of documents

[](#limiting-number-of-documents)

```
// Pull upto 10 documents
$filerdb
  ->database('dev')
  ->collection('users')
  ->limit(10)
  ->get();

```

### Offsetting documents

[](#offsetting-documents)

```
// Pull upto 10 documents, but start at the
// 9th array key.
$filerdb
  ->database('dev')
  ->collection('users')
  ->limit(10, 9)
  ->get();

```

Backups
=======

[](#backups)

You can now programmatically backup your database. You can do so by using the following code:

```
$filerdb->backup->create('file_name_here.zip');

```

This was provided so you can manually backup your database via your own command line script, or automatically via a cron job, or something similar.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

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

Total

5

Last Release

854d ago

Major Versions

v1.2 → v2.0.0.x-dev2023-04-04

### Community

Maintainers

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

---

Top Contributors

[![RobertGrubb](https://avatars.githubusercontent.com/u/13295554?v=4)](https://github.com/RobertGrubb "RobertGrubb (35 commits)")

---

Tags

composercomposer-packagedatabaseflatfilepackagistphpquerydatabaseflatfile

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/robert-grubb-filerdb-php/health.svg)

```
[![Health](https://phpackages.com/badges/robert-grubb-filerdb-php/health.svg)](https://phpackages.com/packages/robert-grubb-filerdb-php)
```

###  Alternatives

[doctrine/dbal

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

9.7k578.4M5.6k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

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

Symfony DoctrineBundle

4.8k241.3M3.3k](/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.8k204.8M440](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k136.1M516](/packages/doctrine-data-fixtures)[robmorgan/phinx

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

4.5k46.2M405](/packages/robmorgan-phinx)

PHPackages © 2026

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