Files
elixforms-web-services/.agents/skills/debug-api-php-con-vs-code-e-docker/SKILL.md
T
2026-07-16 14:42:59 +02:00

47 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Debug API PHP con VS Code e Docker
Questa sezione descrive la procedura per fare debug delle API PHP servite da Docker in questa repository.
## Passaggi
1. Avvia il container Docker dalla root del progetto:
```bash
docker compose up --build
```
2. Apri Visual Studio Code e vai su "Run and Debug".
3. Seleziona la configurazione:
```text
Debug PHP in Docker
```
4. Premi F5 per avviare il debugger.
5. Imposta un breakpoint in un controller, ad esempio in:
```text
src/Api/Controllers/V1/UsersController.php
```
6. Richiama lendpoint tramite browser o curl:
```bash
curl -H "XDEBUG_TRIGGER: 1" http://localhost:8000/api/users
```
## Nota
Il container deve esporre:
- porta `8000` per HTTP
- porta `9003` per Xdebug
Il progetto contiene già i file necessari per il debug:
- `.docker/php/Dockerfile`
- `docker-compose.yml`
- `.vscode/launch.json`
- `.vscode/settings.json`
## Problemi comuni
- Se VS Code non si ferma sul breakpoint, verifica che Xdebug sia abilitato nel container e che la configurazione `client_host` punti a `host.docker.internal`.
- Se il container non si avvia, controlla che Docker Desktop sia in esecuzione.