Skip to content
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

Env: Add ability to specify xdebug.idekey for sake of debugging with PhpStorm/IntelliJ #41171

Open
westonruter opened this issue May 19, 2022 · 4 comments
Labels
[Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.

Comments

@westonruter
Copy link
Member

What problem does this address?

I'm attempting to configure wp-env with Xdebug for PhpStorm/IntelliJ. As I understand, this requires an IDE key for PhpStorm to make the connection with the Debugger. For example, when I have created a server in PhpStorm called amp:

image

I can then run PHPUnit for my plugin with the following command and Xdebug will stop execution at any IDE-specified breakpoints:

wp-env run tests-wordpress 'env PHP_IDE_CONFIG=serverName=amp WORDPRESS_TABLE_PREFIX=wptests_ WP_TESTS_DIR=/var/www/wordpress-develop/tests/phpunit WP_PHPUNIT__TESTS_CONFIG=/var/www/html/phpunit-wp-config.php /var/www/html/wp-content/plugins/amp/vendor/bin/phpunit -c /var/www/html/wp-content/plugins/amp/phpunit.xml.dist

Note the PHP_IDE_CONFIG=serverName=amp environment variable being defined. So that works for the tests environment. However, I'm not having luck with the development environment. I think this is because the xdebug.idekey is undefined in the development instance. The only mention of this configuration I found in the project is #20636 (comment) but it was hardcoded to VSCODE and it didn't end up getting merged.

For context, see ampproject/amp-wp#6802 for attempting to standardize the AMP plugin development environment to use wp-env.

What is your proposed solution?

There could be a way to specify the xdebug.idekey in the .wp-env file.

@westonruter westonruter added the [Tool] Env /packages/env label May 19, 2022
@westonruter
Copy link
Member Author

cc @noahtallen

@westonruter
Copy link
Member Author

Well, I was able to get it to work by configuring the PhpStorm server to have the name localhost, and then to set the host as localhost instead of host.docker.internal. So this may not be needed.

@noahtallen
Copy link
Member

I remember there was a weird thing with the automatic client detection settings here:

// Discover client host does not appear to work on macOS with Docker.
const clientDetectSettings = isLinux
? 'xdebug.discover_client_host=true'
: 'xdebug.client_host="host.docker.internal"';

It feels a bit weird to make the IDE configurable in .wp-env.json, just because different devs might use different IDEs for the same project. Would it make sense to allow it to be passed in from the environment? E.g. if something is on process.env, add it to the Xdebug settings?

@westonruter
Copy link
Member Author

It feels a bit weird to make the IDE configurable in .wp-env.json, just because different devs might use different IDEs for the same project.

I was thinking perhaps it could be supplied via .wp-env.override.json.

Would it make sense to allow it to be passed in from the environment? E.g. if something is on process.env, add it to the Xdebug settings?

I like that.

@jordesign jordesign added the [Type] Enhancement A suggestion for improvement. label Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Tool] Env /packages/env [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

3 participants