This is an example for School API consisting of student
, grade
, and lesson
table. It is built on PHP 7.1.16 with Slim V3 Framework.
- Composer
- MySQL
- Slim V3
- Start MySQL server
- Create database named
schooldb
in MySQL - Open terminal in project directory
- Run
mysql -u root schooldb < db/schooldb.sql
to import database - Run
composer install
to install Slim - Run
php -S localhost:8000
to start the server
- GET
/student/summary/{name}
to get information summary of a student
Example
GET localhost:8000/student/summary/aspen
Result
{
"fullname": "Aspen Lydia",
"class": 2,
"grades": {
"Biology": [
45.25
],
"Chemistry": [
55.61
],
"History": [
52.76
],
"Languages": [
62.58,
68.53,
49.13,
64.57,
37.58
],
"Mathematics": [
82.37,
93.29,
83.29
],
"Religion": [
70.35,
37.84
]
}
}
- POST
/student/add
to add a grade on a lesson of a student
Header
Key | Value |
---|---|
Content-Type | application/json |
Request Body
{
"fullname" : "Aspen Lydia",
"lesson" : "Computers",
"mark" : 95.9
}
Example
GET localhost:8000/student/summary/aspen
Result
{
"message": "Data successfully inserted!"
}