-
Notifications
You must be signed in to change notification settings - Fork 349
[ xdebug ] Add --experimental-ide
option in Playground CLI
#2777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Conversation
--experimental-ide
option to set xdebug path mappings--experimental-ide
option in Playground CLI
Let's support an optional explicit value, e.g. Also, this is the top of my
It means we cannot trivially use |
try { | ||
config = JSON.parse(fs.readFileSync(configFilePath, 'utf-8')); | ||
} catch { | ||
logger.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a big deal, let's display it in red and kill the process at this point. Otherwise, when things don't work, the user will scratch their head and think "oh that option doesn't work?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used jsonc-parser
as suggested in your comment, and it became easier to manipulate JSON.
Now I parse the file and if it finds errors, it logs an error and exits with process.exit(1)
.
My question is, should I use the process.exit() function inside the xdebug-path-mappings file or should I return to the run-cli
file to centralize process.exit functions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! Would throw new Error() suffice? AFAIR CLI has an error handler that already calls exit()
// Then, if xdebug, and experimental IDE are enabled, | ||
// recreate the symlink pointing to the temporary | ||
// directory and add the new IDE config. | ||
if (args.xdebug && args.experimentalIde) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @brandonpayton for reviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brandonpayton and @adamziel, your reviews are warmly welcomed in this pull request, since I am not sure I will list all the use cases.
(c: { $: { name: string } }) => c.$.name === name | ||
); | ||
if (!servers) { | ||
component.servers[0].server.push(server); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line keep failing for me, every part of this expression may be missing (like it was in my config).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had this same experience and believe I've fixed it now.
); | ||
if (!component) { | ||
config.project.component = []; | ||
config.project.component.push({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we set component
to the pushed element?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed now.
XDebug is running even during the Blueprint execution – how cool! Also, that's likely only useful for code developers. Let's set some php.ini option to disable xdebug until WordPress fully boots. |
I've been testing and reviewing the code and made some adjustments. The server host an port are now explicitly configured based on CLI's host and port. I've seen PhpStorm report an Xdebug connection but haven't been able to hit any breakpoints yet. |
I've been testing with an auto-mounted WordPress dir nested under the Playground repo like: |
@adamziel is there any additional step in PhpStorm that I should have to do to tell PhpStorm to be able to hit breakpoints? Or should it just work if you have PhpStorm open and Playground CLI started with Xdebug support? |
I typically check "stop on first line" and set breakpoints from there @brandonpayton. And you need to turn on the "accept debug connections" toggle |
Motivation for the change, related issues
Based on issue #2763
The current pain we have when we run a Playground CLI command with Xdebug enabled is the absence of the files located in the VFS in our IDE.
This pull request gives visibility to the VFS files with the help of a
.playground
symlink and the generation of path mappings inside the developer's IDE.Only the mounts from inside the current working directory are mapped.
Implementation details
.playground
.playground
in the current working directory.--xdebug
and--experimental-ide
options are present, we symlink the temporary playground cli directory inside the current working directory.WP Playground CLI - Listen for Xdebug
in VSCode and PHPStorm config files.--xdebug
and--experimental-ide
options are present, we add IDE configs and path mappings in the related configs.server
with nameWP Playground CLI - Listen for Xdebug
in.idea/workspace.xml
.configuration
with nameWP Playground CLI - Listen for Xdebug
in.vscode/launch.json
.Next
Testing Instructions (or ideally a Blueprint)
CI