JsonDB is a lightweight, document-oriented NoSQL-style database written in PHP. It provides a simple, file-based alternative to traditional databases by storing and managing data as structured JSON files. JsonDB is perfect for lightweight apps, prototyping, local storage, and embedded tools where a full-fledged database system is unnecessary.
- โก Zero-Config: No database server or setup neededโjust PHP and your filesystem.
- ๐งฉ Document-Based: Each collection is a JSON file; each record is a structured JSON document.
- ๐งช CRUD Operations: Easy-to-use API for create, read, update, and delete operations.
- ๐ต๏ธโโ๏ธ Search & Filter: Built-in query capabilities using associative arrays and conditions.
- Coming soon
- ๐ JWT & Session Authentication: Secure API with optional login/auth guard.
- ๐ REST API Wrapper: JSON RESTful interface for HTTP clients.
- ๐๏ธ Transactions & Atomic Writes: Prevents data corruption with locking mechanisms.
- ๐ Replication & Backup Support: Optional add-ons for syncing and restoring data.
- ๐งฐ CLI Tools: Perform operations via command line using Symfony Console.
- ๐ง In-memory Caching: Fast reads with optional caching for large JSON datasets.
- ๐งพ Indexing (Planned): For quicker lookups and searches on large datasets.
- โ Simple: No external dependencies, DB servers, or complex setup.
- โ Portable: Just include it in your projectโworks anywhere PHP runs.
- โ Human-Readable: JSON files are easy to read, edit, version-control, and debug.
- โ Great for Prototyping: Ideal for testing APIs, local apps, and building offline tools.
- โ Customizable: Built in modern PHP (PHP 8.4+), uses OOP, Traits, Enums, and Interfaces.
- ๐ง Rapid API Prototyping
- ๐ Offline Data Storage
- ๐งช Test Mock Databases
- ๐ Configuration/Settings Store
- ๐ฎ Game Save/State Files
- ๐ Lightweight Backend for SPA/JS apps
- ๐ป CLI Data Manipulation Tools
composer require jsondbphp/jsondb
- First create a folder
data
. - Create a
users.json
file inside of data folder.
<?php
require("vendor/autoload.php");
use Json\Database\JsonDB;
// Create DB instance
$db = new JsonDB(__DIR__ . '/data');
// Insert
$db->insert('users', [
'name' => 'Alice',
'email' => 'alice@example.com'
]);
// findAll
$result = $db->findAll('users');
print_r($resull);
// find
$result = $db->find('users', 'name');
print_r($result);
// update
$db->update('users', 'name', 'Alice');
// delete
$db->delete('users', 'name');