
# Mini REST API — PHP + SQLite, all-JSON
rest-api/
├── public/index.php # front controller + router
├── public/router.php # php -S router
├── src/Database.php # SQLite (db/app.db auto-created)
├── src/Response.php # JSON helpers
├── src/TaskController.php # CRUD
├── openapi.json # complete API spec
Run
php -S localhost:8130 -t public public/router.php
Try it
curl http://localhost:8130/api
curl -X POST http://localhost:8130/api/tasks \
-H 'Content-Type: application/json' \
-d '{"title":"Write docs","priority":"high"}'
curl http://localhost:8130/api/tasks
curl http://localhost:8130/api/tasks/1
curl -X PATCH http://localhost:8130/api/tasks/1 \
-H 'Content-Type: application/json' -d '{"done":true}'
curl -X DELETE http://localhost:8130/api/tasks/1
List supports ?done=0|1&q=...&page=&per_page=. All responses are
{ok, data} or {ok:false, error} with proper status codes
(200/201/404/405/422).
Top comments (0)