Skip to content

CodeWithSushil/json-db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

44 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

  • 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');

About

JsonDB: Lightweight Document Container for Modern PHP Apps.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy