flat
flat copied to clipboard
A flat file database for PHP
Flat
Flat is a flat-file database with a mongo-like API, written in PHP.
⚠️ Still under heavy development!
Inserting documents
$db = Flat::localDatabase("/path/to/db");
$doc = new Document([
'title' => 'Flat',
'description' => 'A flat NoSQL database',
]);
$db->collection('pages')->insert($doc);
Finding documents
$db->collection('pages')->find(['published' => true]);
// Something slightly more complex
$db->collection('pages')->find([
'published' => true,
'view_count' => [ '$gt' => 1000 ],
'author' => ['$in' => [ 'john', 'jane', 'jack']]
]);
// Or with boolean combination
$db->collection('pages')->find([
'$or' => [
['published' => false],
['author' => 'admin']
]
]);
Supported query operators
Logical: $and, $or, $not.
Comparison: $eq, $gt, $gte, $lt, $lte, $ne, $regex.
Array: $in, $nin.
Removing documents
$db->collection('pages')->remove(['published' => false]);

