https://github.com/codewithsushil/json-db
JSON DB for APIs Testing and minimalist project
https://github.com/codewithsushil/json-db
json-api json-database json-db json-server
Last synced: 2 months ago
JSON representation
JSON DB for APIs Testing and minimalist project
- Host: GitHub
- URL: https://github.com/codewithsushil/json-db
- Owner: CodeWithSushil
- License: mit
- Created: 2025-01-20T01:45:57.000Z (11 months ago)
- Default Branch: master
- Last Pushed: 2025-01-27T10:31:04.000Z (11 months ago)
- Last Synced: 2025-01-27T11:42:27.681Z (11 months ago)
- Topics: json-api, json-database, json-db, json-server
- Language: PHP
- Homepage:
- Size: 50.8 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README

[](https://github.com/CodeWithSushil/json-db/actions/workflows/tests.yml)





**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.
---
## ๐ Features
- โก **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.
- [x] 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.
---
## ๐ฆ Why Use JsonDB?
- โ
**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.
---
## ๐ก Use Cases
- ๐ง 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
---
## ๐งโ๐ป How It Works
#### Install
```bash
composer require jsondbphp/jsondb
```
#### Example
- First create a folder `data`.
- Create a `users.json` file inside of data folder.
```php
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');
```
---