feat: one-command Xdebug step-debugging (kiqr xdebug on/off)#30
Open
kjellbergzoey wants to merge 1 commit into
Open
feat: one-command Xdebug step-debugging (kiqr xdebug on/off)#30kjellbergzoey wants to merge 1 commit into
kjellbergzoey wants to merge 1 commit into
Conversation
The official `wordpress` image ships without Xdebug, so enabling step
debugging previously meant hand-rolling a custom image. This adds
`kiqr xdebug on|off` to toggle a machine-local flag that, when on, makes
the wordpress service build from a tiny generated Dockerfile that layers
Xdebug onto the same php-pinned base image.
- src/lib/xdebug.ts: pure generators for the Dockerfile + ini plus
write/remove FS helpers (fully unit-tested).
- RuntimeConfig gains `xdebugEnabled`; ComposeService.image is now
optional and gains an optional `build`. When enabled, the wordpress
service uses `build: {context, dockerfile: xdebug.Dockerfile}` and an
extra `host.docker.internal:host-gateway` host so the debugger can
reach the IDE on the host. Disabled behavior is byte-for-byte as before.
- config: `xdebug?: boolean` is machine-local and optional (absent = off,
backward compatible).
- up/restart thread the flag and (re)generate the assets during
"Preparing site". The xdebug command never runs Docker; it tells the
user to `kiqr restart` to apply.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
kiqr xdebug on|offfor one-command Xdebug step-debugging of theme/PHP code.Why / approach
The official
wordpressimage ships without Xdebug, so it can't simply be enabled via an env var. Instead, when Xdebug is turned on, thewordpressservice is built from a tiny generated Dockerfile that layers Xdebug onto the same php-pinned base image:The generated
xdebug.iniruns inmode=debug,start_with_request=yes, and connects out tohost.docker.internal:9003, with a matchingextra_hosts: host.docker.internal:host-gatewayadded to the service so the container can reach the IDE on the host.When Xdebug is off, the compose output is byte-for-byte identical to today (
image:, single hostnameextra_host).mariadb/wpcli/phpmyadminare untouched.Details
src/lib/xdebug.ts(new, pure + unit-tested):buildXdebugDockerfile,xdebugIni,writeXdebugAssets,removeXdebugAssets.xdebug?: booleanadded toLocalConfigand the zodlocalConfigSchema. It's machine-local (debugging is a per-developer choice) and optional — absent means off, so existing configs keep working.RuntimeConfiggainsxdebugEnabled;ComposeService.imageis now optional and gains an optionalbuild.up/restartreadlc.xdebug, threadxdebugEnabled, and (re)generate or clean up the assets during the "Preparing site" step.kiqr xdebug <on|off>validates the arg (on/off) via zod, flips the local flag, writes/removes the assets, and prints a message to runkiqr restartto apply. It does not run Docker.Applying it / IDE side
kiqr restart(or the nextkiqr up) to apply. The first start after enabling rebuilds the WordPress image, so it's slower once.Not verified without Docker
There is no Docker daemon in this environment, so I could only unit-test the generators and the compose wiring. The following were NOT verified end-to-end:
pecl install xdebug && docker-php-ext-enable xdebugactually builds against everywordpress:php*base tag.host.docker.internal:9003.Only the pure generators (
xdebug.ts), the config schema, and the provider's compose output are covered by tests.Follow-ups
launch.json(VS Code "Listen for Xdebug") is a planned follow-up.🤖 Generated with Claude Code