Skip to content

Commit 59740fd

Browse files
Update README.md
1 parent d394fe9 commit 59740fd

File tree

2 files changed

+24
-37
lines changed

2 files changed

+24
-37
lines changed

README.md

Lines changed: 23 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,36 @@
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+

src/JSONDatabase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?php
22
namespace App;
3+
use Exception;
34

45
class JSONDatabase {
56
private $filePath;

0 commit comments

Comments
 (0)