Description
Build the PHP routing layer that maps HTTP method + path to controllers, handles CORS for the React frontend, and sets up global error handling. This is the backbone of the entire backend.
Tasks
Acceptance Criteria
- All API requests go through
index.php
- CORS headers allow requests from the React frontend
- Router correctly maps paths including parameters
- Unknown routes return clean JSON 404
Description
Build the PHP routing layer that maps HTTP method + path to controllers, handles CORS for the React frontend, and sets up global error handling. This is the backbone of the entire backend.
Tasks
public/index.phpas the single entry point (front controller).htaccessinpublic/to rewrite all requests toindex.phphelpers/Router.php:/projects/:id)routes/api.phphttp://localhost:5173) and handleOPTIONSpreflightContent-Type: application/jsonfor all responseshelpers/Response.phpwithsuccess($data, $code)anderror($message, $code)helpersGET /api/pingreturns{"status": "ok"}{"error": "Not found"}with 404Acceptance Criteria
index.php