An open API service indexing awesome lists of open source software.

https://github.com/ronaldaug/sim-rest

JSON based lightweight PHP rest api
https://github.com/ronaldaug/sim-rest

Last synced: 5 months ago
JSON representation

JSON based lightweight PHP rest api

Awesome Lists containing this project

README

        

# Sim-Rest
Sim-Rest is super lightweight tool that can serve your JSON file as a fully functional RESTFUL API.

### Features
- Only 10 KB (gzip)
- PHP 7+
- Router (GET, POST, DELETE, PUT)
- Pass parameter through router
- JSON file database
- JWT like token based authentication
- Auth protected routes
- Eloquent like DB selector
- Less configuration
- Zero dependencies

---------

## Only 3 steps to make your json file to fully functional REST API with JWT token auth.

#### 1
Add your JSON data under `database/collections` folder. (There are two sample json dbs called `posts` and `cars`)

#### 2
Change username and password or add new users in `database/config.php` file.

#### 3
Delare routes inside main `index.php`

Examples

**Public Route**
```php

$router->get('/posts',function(){
$posts = DB::table("posts")->all();
echo json_encode($posts);
});

```

**Protected Route**
```php
if($auth->routes()){

$router->get('/posts',function(){
$posts = DB::table("posts")->all();
echo json_encode($posts);
});

}
```

> Here, you'll see the database queries but most are very similar with Laravel eloquent.

-------

That's it, just upload on hosting or serve via xampp/mamp and you're ready to fetch data via REST API.

Still don't get it? please check the documentation and example of todo API below.

## Documentation
[https://ronaldaug.gitbook.io/sim-rest/](https://ronaldaug.gitbook.io/sim-rest/)

## How to make a simple todo API
https://medium.com/@ronaldaug/php-restful-api-with-sim-rest-only-10-kb-422da0738e30

--------

Show your support by ๐ŸŒŸthe project, Thanks