webtech-projects

REST API Extension

Second part of the WebTech project sequence. This project extends the original PHP database site with a REST API, protected admin workflows, JSON import, and API documentation.

What It Includes

Main API Endpoints

Method Endpoint Purpose
GET /api/olympians List athletes, with optional filters
GET /api/olympians/{id} Read one athlete detail
POST /api/olympians Create an athlete/result entry
POST /api/olympians/bulk Import multiple entries from JSON
PUT /api/olympians/{id} Update an entry
DELETE /api/olympians/{id} Delete an entry

Key Files

Local Setup

  1. Install dependencies:

    composer install
    
  2. Create a local config file:

    cp config/config.example.php config/config.php
    
  3. Fill in database credentials, OAuth credentials if needed, and a long random API_JWT_SECRET.

  4. Import the schema from sql/table.sql.

  5. Serve public/ with PHP and configure the API route so requests to /api/... reach api/index.php.

Security Notes

config/config.php, real OAuth credentials, JWT secrets, SQL dumps with user data, archives, and vendor/ are not committed. Use config/config.example.php as the template for local setup.