File tree Expand file tree Collapse file tree 2 files changed +24
-37
lines changed Expand file tree Collapse file tree 2 files changed +24
-37
lines changed Original file line number Diff line number Diff line change 11## json-db
22- JSON DB for APIs Testing for Your Minimalist Project
33
4- ## Installation
4+ ### Example
5+ Full example of json db
6+ ``` php
7+ <?
58
6- ``` bash
7- git clone https://github.com/codewithsushil/json-db.git
8- cd json-db
9- php -S localhost:8888
10- curl http://localhost:8888
11- ```
9+ require "vendor/autoload.php";
1210
13- ## setup
14- ``` php
15- $db = new jsondb(__dir__);
11+ use App\JSONDatabase;
1612
17- ```
13+ $path = 'data/users.json';
1814
19- ## Post
20- ``` php
21- $db->post("users", [
15+ $db = new JSONDatabase($path);
16+
17+ $data = [
2218 'id' => 1,
23- 'name' => 'jhon ',
24- 'email ' => 'jhon@example.com' ,
25- 'create_at ' => '20:34:05:05:2025'
26- ]);
27- ```
19+ 'name' => 'Sushil ',
20+ 'age ' => 23 ,
21+ 'dev ' => true,
22+ 'lang' => ['php','javascript','sql']
23+ ];
2824
29- ## Get
30- ``` php
31- $db->get("users", true); // all data
32- $db->get("users", $id); // single data
33- ```
25+ // post data
26+ $db->write($data);
3427
35- ## update
36- ``` php
37- $db->update("users",$id, [
38- 'name' => 'lily'
39- ])
40- ```
28+ // fetch data
29+ $result = $db->read();
4130
42- ## delete
43- ``` php
44- $db->delete("users", $id);
45- ```
31+ echo "<pre >";
32+ print_r($result);
33+ echo "</pre >";
4634
47- ## search or like?
48- ```
49- $db->search('users','jhon');
5035```
36+
Original file line number Diff line number Diff line change 11<?php
22namespace App ;
3+ use Exception ;
34
45class JSONDatabase {
56 private $ filePath ;
You can’t perform that action at this time.
0 commit comments