PHPackages                             jsondbphp/jsondb - 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. jsondbphp/jsondb

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

jsondbphp/jsondb
================

JsonDB: Lightweight Document Container for Modern PHP Apps.

v1.0.0(10mo ago)361MITPHPPHP ^8.2CI passing

Since Jun 28Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/CodeWithSushil/json-db)[ Packagist](https://packagist.org/packages/jsondbphp/jsondb)[ Fund](https://www.buymeacoffee.com/codewithsushil)[ Fund](https://paypal.me/codewithsushil)[ RSS](/packages/jsondbphp-jsondb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (3)Used By (0)

[![JsonDB](/art/jsondb.png)](/art/jsondb.png)

[![Tests](https://github.com/CodeWithSushil/json-db/actions/workflows/tests.yml/badge.svg)](https://github.com/CodeWithSushil/json-db/actions/workflows/tests.yml)[![Packagist Version](https://camo.githubusercontent.com/dc5905a96e37e4a4e6bf92b28c6e2107d4c9596f90451ddbc66ffc07004ab620/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a736f6e64627068702f6a736f6e64623f7374796c653d666c6174266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d253233666666)](https://camo.githubusercontent.com/dc5905a96e37e4a4e6bf92b28c6e2107d4c9596f90451ddbc66ffc07004ab620/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a736f6e64627068702f6a736f6e64623f7374796c653d666c6174266c6f676f3d636f6d706f736572266c6f676f436f6c6f723d253233666666)[![Packagist Dependency Version](https://camo.githubusercontent.com/952fcd75da937dfb7ee87013665f47542af673285e3f3181679a45746d82aa7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a736f6e64627068702f6a736f6e64622f7068703f7374796c653d666c6174266c6f676f3d706870266c6f676f436f6c6f723d626c7565266c6162656c3d50485026636f6c6f723d626c7565)](https://camo.githubusercontent.com/952fcd75da937dfb7ee87013665f47542af673285e3f3181679a45746d82aa7c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f6a736f6e64627068702f6a736f6e64622f7068703f7374796c653d666c6174266c6f676f3d706870266c6f676f436f6c6f723d626c7565266c6162656c3d50485026636f6c6f723d626c7565)[![Packagist License](https://camo.githubusercontent.com/58f0c9770b2c0f791e6cd10e8ad7bad52895407c6f43c852c794960574cb21fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a736f6e64627068702f4a736f6e64623f7374796c653d666c6174266c6162656c3d4c6963656e736526636f6c6f723d626c7565)](https://camo.githubusercontent.com/58f0c9770b2c0f791e6cd10e8ad7bad52895407c6f43c852c794960574cb21fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a736f6e64627068702f4a736f6e64623f7374796c653d666c6174266c6162656c3d4c6963656e736526636f6c6f723d626c7565)[![Packagist Downloads](https://camo.githubusercontent.com/83d0f2e9cc18a6830c8ec8999e714bdf645a5ba974bd1a35419815af61dd542e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a736f6e64627068702f4a736f6e64623f7374796c653d666c6174266c6162656c3d446f776e6c6f61647326636f6c6f723d626c7565)](https://camo.githubusercontent.com/83d0f2e9cc18a6830c8ec8999e714bdf645a5ba974bd1a35419815af61dd542e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a736f6e64627068702f4a736f6e64623f7374796c653d666c6174266c6162656c3d446f776e6c6f61647326636f6c6f723d626c7565)[![Packagist Stars](https://camo.githubusercontent.com/44510760e6f549e25465eaabc23dd6abce3f819819b735eadcde5177d7802550/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6a736f6e64627068702f6a736f6e64623f7374796c653d666c6174266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d253233666666666666266c6162656c3d2546302539462538432539462532305374617273)](https://camo.githubusercontent.com/44510760e6f549e25465eaabc23dd6abce3f819819b735eadcde5177d7802550/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f73746172732f6a736f6e64627068702f6a736f6e64623f7374796c653d666c6174266c6f676f3d7061636b6167697374266c6f676f436f6c6f723d253233666666666666266c6162656c3d2546302539462538432539462532305374617273)

**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
----------

[](#-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 &amp; Filter:** Built-in query capabilities using associative arrays and conditions.
- Coming soon
- 🔐 **JWT &amp; Session Authentication:** Secure API with optional login/auth guard.
- 🌐 **REST API Wrapper:** JSON RESTful interface for HTTP clients.
- 🗃️ **Transactions &amp; Atomic Writes:** Prevents data corruption with locking mechanisms.
- 🔁 **Replication &amp; 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?
-----------------

[](#-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
-----------

[](#-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
----------------

[](#‍-how-it-works)

#### Install

[](#install)

```
composer require jsondbphp/jsondb
```

#### Example

[](#example)

- First create a folder `data`.
- Create a `users.json` file inside of data folder.

```
