Skip to content

CodeWithSushil/json-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

39 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

JsonDB

Tests Packagist Version Packagist Dependency Version Packagist License Packagist Downloads Packagist Stars

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.
  • 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

composer require jsondbphp/jsondb

Example

// index.php require("vendor/autoload.php"): use Json\Database; // Create DB instance $db = new JsonDB(__DIR__ . '/data'); // Insert $id = $db->collection('users')->insert([ 'name' => 'Alice', 'email' => 'alice@example.com' ]); // Find $user = $db->collection('users')->find($id); // Update $db->collection('users')->update($id, ['email' => 'new@example.com']); // Delete $db->collection('users')->delete($id);

About

JsonDB: Lightweight Document Container for Modern PHP Apps.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages