✅ API REST — Gestionnaire de Tâches

Module 08 — API REST · Mini-projet

🎯 Endpoints

MéthodeURLDescription
GET/api/tasksLister toutes les tâches
GET/api/tasks/{id}Récupérer une tâche
POST/api/tasksCréer une tâche (201)
PUT/api/tasks/{id}Modifier une tâche
DELETE/api/tasks/{id}Supprimer (204)
GET/api/meProfil (auth requis)

🔐 Auth

Header : Authorization: Bearer {token}

Tokens : tok-alice (Alice) · tok-bob (Bob)

▶ Tester l'API

cd formation-php/08-api-rest/mini-projet
php -S localhost:8000

# Liste des tâches
curl http://localhost:8000/api/tasks

# Créer une tâche (auth)
curl -X POST http://localhost:8000/api/tasks \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer tok-alice" \
  -d '{"titre":"Ma tâche","priorite":"haute"}'

# Supprimer
curl -X DELETE http://localhost:8000/api/tasks/1 \
  -H "Authorization: Bearer tok-alice"

✅ Solution + Interface

▶ Ouvrir l'API 🖥️ Interface Web