Module 08 — API REST · Mini-projet
| Méthode | URL | Description |
|---|---|---|
| GET | /api/tasks | Lister toutes les tâches |
| GET | /api/tasks/{id} | Récupérer une tâche |
| POST | /api/tasks | Créer une tâche (201) |
| PUT | /api/tasks/{id} | Modifier une tâche |
| DELETE | /api/tasks/{id} | Supprimer (204) |
| GET | /api/me | Profil (auth requis) |
Header : Authorization: Bearer {token}
Tokens : tok-alice (Alice) · tok-bob (Bob)
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"