OpenCode REST API Application with PHP and SQLITE
# 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/Respons
# 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
bash
php -S localhost:8130 -t public public/router.php
## Try it
bash
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).
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.