Adopt and document Xdebug for PHP projects created in Firebase Studio
Summary Recommend Xdebug as the default debugger for PHP projects scaffolded by Firebase Studio, with a simple setup guide to enable breakpoints, variable inspection, and stack traces for local runs and when using the Firebase Emulator Suite.
Why
Step-by-step debugging with breakpoints directly in the IDE.
Real-time variable/watch inspection and stack traces.
Faster diagnosis of issues in integrations with Auth, Firestore, Realtime Database, Storage, and FCM.
Minimal setup (project template)
php.ini (or a project-specific .ini):
zendextension=xdebug
xdebug.mode=debug,develop
xdebug.startwithrequest=yes
xdebug.clientport=9003
xdebug.clienthost=host.docker.internal (use 127.0.0.1 or host IP on Linux)
.env defaults:
XDEBUGMODE=debug
XDEBUGCLIENTPORT=9003
XDEBUGCLIENTHOST=host.docker.internal
IDE integration
VS Code: install “PHP Debug”, enable “Listen for Xdebug”, configure path mappings if using Docker.
PhpStorm: enable “Listen for PHP Debug Connections”, configure a Server with correct host and path mappings.
Docker/WSL tips
Use host.docker.internal on macOS/Windows; on Linux, use the host/gateway IP (e.g., from ip route | grep default).
Ensure port 9003 is exposed and allowed by the firewall.
Best practices
Enable Xdebug only in development; disable in production.
Keep logging minimal by default (xdebug.log_level=0); increase only when diagnosing issues.
Avoid logging or dumping secrets and tokens.
Emulator Suite integration
Provide a “Dev with Emulator” run profile that sets emulator env vars (e.g., FIRESTOREEMULATORHOST, etc.) alongside the Xdebug vars, enabling breakpoints while testing against emulators.