Skip to content

Commit b0fd1fd

Browse files
README.md Update with example docs
1 parent fe26d67 commit b0fd1fd

File tree

1 file changed

+80
-2
lines changed

1 file changed

+80
-2
lines changed

README.md

Lines changed: 80 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,85 @@
1+
**JsonDB:** Lightweight Document Container for Modern PHP Apps.
2+
13
![JsonDB](/art/jsondb.png)
24

35
[![Tests](https://github.com/CodeWithSushil/json-db/actions/workflows/tests.yml/badge.svg)](https://github.com/CodeWithSushil/json-db/actions/workflows/tests.yml)
6+
![Packagist Version](https://img.shields.io/packagist/v/jsondbphp/jsondb?style=flat&logo=composer&logoColor=%23fff)
7+
![Packagist Dependency Version](https://img.shields.io/packagist/dependency-v/jsondbphp/jsondb/php?style=flat&logo=php&logoColor=blue&label=PHP&color=lime)
8+
![Packagist License](https://img.shields.io/packagist/l/jsondbphp/Jsondb?style=flat&label=License&color=blue)
9+
![Packagist Downloads](https://img.shields.io/packagist/dt/jsondbphp/Jsondb?style=flat&label=Downloads&color=blue)
10+
![Packagist Stars](https://img.shields.io/packagist/stars/jsondbphp/jsondb?style=flat&logo=packagist&logoColor=%23ffffff&label=%F0%9F%8C%9F%20Stars)
11+
12+
13+
**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.
14+
15+
---
16+
17+
## 🚀 Features
18+
19+
-**Zero-Config:** No database server or setup needed—just PHP and your filesystem.
20+
- 🧩 **Document-Based:** Each collection is a JSON file; each record is a structured JSON document.
21+
- 🧪 **CRUD Operations:** Easy-to-use API for create, read, update, and delete operations.
22+
- 🕵️‍♂️ **Search & Filter:** Built-in query capabilities using associative arrays and conditions.
23+
- 🔐 **JWT & Session Authentication:** Secure API with optional login/auth guard.
24+
- 🌐 **REST API Wrapper:** JSON RESTful interface for HTTP clients.
25+
- 🗃️ **Transactions & Atomic Writes:** Prevents data corruption with locking mechanisms.
26+
- 🔁 **Replication & Backup Support:** Optional add-ons for syncing and restoring data.
27+
- 🧰 **CLI Tools:** Perform operations via command line using Symfony Console.
28+
- 🧠 **In-memory Caching:** Fast reads with optional caching for large JSON datasets.
29+
- 🧾 **Indexing (Planned):** For quicker lookups and searches on large datasets.
30+
31+
---
32+
33+
## 📦 Why Use JsonDB?
34+
35+
-**Simple:** No external dependencies, DB servers, or complex setup.
36+
-**Portable:** Just include it in your project—works anywhere PHP runs.
37+
-**Human-Readable:** JSON files are easy to read, edit, version-control, and debug.
38+
-**Great for Prototyping:** Ideal for testing APIs, local apps, and building offline tools.
39+
-**Customizable:** Built in modern PHP (PHP 8.4+), uses OOP, Traits, Enums, and Interfaces.
40+
41+
---
42+
43+
## 💡 Use Cases
44+
45+
- 🔧 Rapid API Prototyping
46+
- 🗃 Offline Data Storage
47+
- 🧪 Test Mock Databases
48+
- 🛠 Configuration/Settings Store
49+
- 🎮 Game Save/State Files
50+
- 🌐 Lightweight Backend for SPA/JS apps
51+
- 💻 CLI Data Manipulation Tools
52+
53+
---
54+
55+
## 🧑‍💻 How It Works
56+
57+
```php
58+
use JsonDB\JsonDB;
59+
60+
// Create DB instance
61+
$db = new JsonDB(__DIR__ . '/data');
62+
63+
// Insert
64+
$id = $db->collection('users')->insert([
65+
'name' => 'Alice',
66+
'email' => 'alice@example.com'
67+
]);
68+
69+
// Find
70+
$user = $db->collection('users')->find($id);
71+
72+
// Update
73+
$db->collection('users')->update($id, ['email' => 'new@example.com']);
74+
75+
// Delete
76+
$db->collection('users')->delete($id);
77+
```
78+
79+
---
480

5-
JsonDB: Lightweight document container.
81+
## Install
682

7-
___
83+
```bash
84+
composer require jsondbphp/jsondb
85+
```

0 commit comments

Comments
 (0)