A simple example of PHP REST API framework, built from scratch using vanilla PHP.
- git clone the repo
- cd into project folder
- use docker-compose
jun@b:~$ docker-compose up --build
- you might get error about mysql not connect, just wait until mysql container up and running and refresh the page.
- stop the container
jun@b:~$ docker-compose down
- the core directory contains the core framework code.
- contains our app code,
- we define the routes in the
App\Routes
folder and all files in this folder will be loaded. - we define our models in
App\Models
extending theCore\Model
class. - we define our controllers in
App\Controllers
extending theCore\Controllers
class.
- this is the main entry point of our application. request from
nginx
get redirected topublic/index.php
.
this is just a simple example, I will update new things if I have time and ideas to do it.
Things to add:
- Sessions, and authentication example, using JWT
- Token expired and refresh token example
- using external environment-variable file.
- file upload example.