Sim-Rest is super lightweight tool that can serve your JSON file as a fully functional RESTFUL API.
- 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
Add your JSON data under database/collections
folder. (There are two sample json dbs called posts
and cars
)
Change username and password or add new users in database/config.php
file.
Delare routes inside main index.php
Examples
Public Route
$router->get('/posts',function(){
$posts = DB::table("posts")->all();
echo json_encode($posts);
});
Protected Route
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.
https://ronaldaug.gitbook.io/sim-rest/
https://medium.com/@ronaldaug/php-restful-api-with-sim-rest-only-10-kb-422da0738e30
Show your support by 🌟the project, Thanks