php-perfect / ddev-intellij-plugin

DDEV Tool Integration for IntelliJ IDEA
https://plugins.jetbrains.com/plugin/18813-ddev-integration
BSD 3-Clause "New" or "Revised" License
109 stars 15 forks source link

Default "DDEV" server name isn't compatible with all xdebug scenarios #227

Closed ultimike closed 10 months ago

ultimike commented 1 year ago

Is there an existing issue for this?

Are you sure that this bug is related to this DDEV Integration Plugin?

Enter your error report ID (If available)

No response

Describe the bug

By default, when this plugin creates the "DDEV" configuration "PHP | Servers", it uses the name "DDEV" with a "Host" of SITE_NAME.ddev.site. This works for most debugging situations.

I have found, however, that when debugging PhpUnit tests, the name "DDEV" must be replaced with the same value as the "Host" (SITE_NAME.ddev.site).

Steps to reproduce

  1. Try to debug a PhpUnit test using the default server configuration - it won't work.
  2. Change the "PHP | Servers" name from DDEV to SITE_NAME.ddev.site and debugging of PhpUnit tests will work.

My setup is pretty standard, I am using the standard phpunit.xml file from Drupal core moved to the project root (with updated paths).

When I make this change above, I think the DDEV plugin recreates a new server configuration with the name "DDEV". This does not affect my ability to use xdebug on PhpUnit tests nor non-test-code situations.

Additional context

This is very loosely related to #220

rfay commented 1 year ago

I do think this is likely a PhpStorm bug, rather than an issue of the plugin here, but it could obviously be worked around here.

It could be raised upstream in https://youtrack.jetbrains.com/issues?q=project:%20PhpStorm but would need a very careful repro, which wouldn't use this plugin. But it should be demonstrable by manually creating the "server".

And let's get them to change the name "server" to something useful while we're at it :)

ultimike commented 1 year ago

So, demonstrate how to reproduce the issue when manually creating a "Server" and showing how Xdebug doesn't work unless the "Name" is the same?

rfay commented 1 year ago

Yes, that's what I'm suggesting. It's too difficult a problem for the PhpStorm folks unless a great and simple repro is provided.

nico-loeber commented 1 year ago

Thanks for reporting @ultimike!

The generated config could be changed to this naming pattern, but it makes it more complicated to update it. If the config name is changed by the ddev configuration (name of the ddev project) a new configuration would be generated instead of updating the current one, as the plugin no longer knows the old name of the project. Of course you could work with pattern matching and remove *.ddev.site configurations that do not fit the current project name, but maybe someone added them by intention. So please keep me updated regarding the PHPStorm issue.

kevinquillen commented 11 months ago

This doesn't work out of the box for Kernel/Functional tests especially ones that test HTTP, session, cookie or routing data.

I had to do the following:

Only until I did that could I run xdebug to inspect all test types.

image
rfay commented 11 months ago

The reality is that the server name should be the canonical name of the project, for best usability. Thanks all for following up on this. It would be great to change the "server" name to the site FQDN, as PhpStorm does by default and always has.

kevinquillen commented 11 months ago

Yes, I ran into this same issue with Docker4Drupal in the past. The IDE key was PHPSTORM and the server name also had to be PHPSTORM or it wouldn't work.

Previous projects:

PHP_IDE_CONFIG: serverName=PHPSTORM
PHP_XDEBUG_IDEKEY: "PHPSTORM"

Even though the docs say the host name doesn't matter there, I always found that it did along with name.

RuZniki commented 11 months ago

Hey, I also get the same problem with ddev, PHP Storm, xdebug. I was trying to run PHP unit tests from PHP Storm UI, and the mapping didn't work. Running PHP unit tests from CLI also have this issue. And it was so unexpected that changing server name will fix this, I think that main thing is host settings.

As solution/workaround

  1. provide notification message, when server configuration created that it's better to change server name.
  2. Update ddev documentation page https://ddev.readthedocs.io/en/latest/users/debugging-profiling/step-debugging/. Put info about server name.
rfay commented 11 months ago

We should turn this into an issue.

rfay commented 11 months ago

Opened

nico-loeber commented 10 months ago

The plugin will now use the primary fqdn of the ddev environment as name of the server configuration and will reference this configuraton for updates by its uid. This technique is now also used for some other configurations for a better change management of the configurations.

deviantintegral commented 10 months ago

Nice! Any chance it can work for multisites that have multiple FQDNs? Currently you can make it work by copying and editing a configuration. That would normally be fine I think - except that when you forget, debugging just silently doesn't work and it's difficult to realize what the problem is.