https://github.com/inambe/php-rest-api
Simple Slim-PHP Rest API
https://github.com/inambe/php-rest-api
api authentication php slim token
Last synced: about 1 year ago
JSON representation
Simple Slim-PHP Rest API
- Host: GitHub
- URL: https://github.com/inambe/php-rest-api
- Owner: Inambe
- License: mit
- Created: 2018-04-07T16:35:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-04-19T02:04:26.000Z (about 8 years ago)
- Last Synced: 2025-02-01T14:16:59.255Z (over 1 year ago)
- Topics: api, authentication, php, slim, token
- Language: PHP
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP Rest API
This template puts three PHP libraries together for producing simple yet powerful/useful APIs
## Installation
Download as zip and extract (Rename the folder as you required)
cd into folder:
```
cd yourfolder
```
update dependencies
```
composer update
```
Once installation is finished, Go to ``` localhost/yourfolder/ ``` you will see:
```
{
"msg": "Hello World!"
}
```
## Basic Usage
For creating routes as your requirement, You need to create file for every route group in ``` routes/ ``` folder
(DON'T Forget to add ```__``` prefix to file names).
For example, if you are creating API for Managing books table into your database, your route file name should be like ```__books.php```. In this file you'll have all the routes for managing books table into your database.
Instead of creating seprate files for every group of routes, You can put all routes into a single file (It's bad).
Read more about routing in [Slim Docs](https://www.slimframework.com/docs/)
## Interacting with Database
You need to change ```using_db``` option to ```true ``` in ```config/app.php``` and also add your database credentials there.
You can then access Medoo database object in your route's callback function like this ``` $this->db ... ```.
Read more about [Medoo](https://medoo.in/doc) (It's Super Simple)