prowebcraft/php-json-db

Simple And Flexible database in JSON file

0.1.4 2021-02-25 05:58 UTC

This package is auto-updated.

Last update: 2024-10-29 04:09:15 UTC


README

Simple And Flexible database in JSON file

#Installation

composer require prowebcraft/php-json-db

#Usage Create JsonDb instance

$db = new \Prowebcraft\JsonDb([
  'name' => 'users.json',
  'dir' => getcwd()
]);

Add some data

$db->set('user', [
    'firstname' => 'John',
    'lastname' => 'Doe'
]);

Add more data to existing array

$db->set('user.age', 18);

Save data to storage

$db->save();

You will get file in current working directory named users.json with sample data:

{
    "user": {
        "firstname": "John",
        "lastname": "Doe",
        "age": 18
    }
}

Get items

$db->get('user.age');