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

xdebug with phpstorm #160

Open
gcalex5 opened this issue May 4, 2022 · 4 comments
Open

xdebug with phpstorm #160

gcalex5 opened this issue May 4, 2022 · 4 comments

Comments

@gcalex5
Copy link

gcalex5 commented May 4, 2022

Are there any docs or guides available for getting the platformsh lando recipe working with xdebug and phpstorm that someone could point me at?

Had seen this one, and was able to verify that the xdebug extension was loading. However, wasn't able to pick up a connection with phpstorm using that.

Have also tried something like this with no luck in my .lando.yml(phpstorm is configured to localhost with the root of project and web directory mapped to app and /app/web respectively):

name: <name>
recipe: platformsh
config:
  id: <id>
  overrides:
    app:
      runtime:
        extensions:
          - redis
          - xdebug
      php:
        # XDEBUG 3
        xdebug.mode: debug
        xdebug.max_nesting_level: 1024
        xdebug.client_port: 9003
        xdebug.show_exception_trace: 0
        xdebug.collect_params: 0
        xdebug.remote_autostart: 1
        xdebug.start_with_request: yes
@ChexWarrior
Copy link

ChexWarrior commented May 6, 2022

@gcalex5 Have you been able to verify that the settings you specified in the .lando.yml are even taking effect? I'm also trying to get it working and it doesn't seem like any of the overridden xdebug vars are actually making a difference.

name: <name>
recipe: platformsh
config:
  id: <id>
  overrides:
    app:
      runtime:
        extensions:
          - xdebug
          - redis
          - apcu
      php:
        xdebug.mode: debug
        xdebug.client_port: 9003
        xdebug.client_host: 172.17.0.1
        xdebug.start_with_request: yes
        xdebug.idekey: lando
        xdebug.log: /tmp/php-xdebug.log

@ChexWarrior
Copy link

ChexWarrior commented May 6, 2022

So I found this issue #51 and the way they setup the .lando.yml actually seems to work, I'll keep playing with it. Note that I had to enable the xdebug extension in my .platform.app.yaml.

Updated .lando.yml:

name: <name>
recipe: platformsh
config:
  id: <id>
  variables:
    app:
      php:
        xdebug.mode: debug
        xdebug.client_port: 9003
        xdebug.client_host: 172.17.0.1
        xdebug.start_with_request: yes
        xdebug.idekey: lando
        xdebug.log: /tmp/php-xdebug.log

@ChexWarrior
Copy link

ChexWarrior commented May 6, 2022

Okay got it working for page requests with PHPStorm:

# .lando.yml
name: <name>
recipe: platformsh
config:
  id: <id>
  variables:
    app:
      php:
        xdebug.mode: debug
        xdebug.client_port: 9003
        xdebug.client_host: 172.17.0.1
        xdebug.start_with_request: yes
        xdebug.idekey: lando
        xdebug.log: /tmp/php-xdebug.log
# excerpt in .platform.app.yaml
...
variables:
  php:
    ...
  env:
    XDEBUG_CONFIG: "client_host=172.17.0.1"
    PHP_IDE_CONFIG: serverName=lando

runtime:
  extensions:
   ...
    - xdebug
...

In PHPStorm I have a Debug configuration setup with a type of PHP Web Page and using a Server configuration named lando that has path mappings setup from my project root to the /app within the app container.

Just to explain a few other things:

I use a client_host of 172.17.0.1 since that represents the host's IP from within the app container on a Linux machine (on Windows and Mac you should be able to use host.docker.internal).

Not 100% sure on why this is but I had to specify client_host twice as only specifying it in the variables config didn't seem to remove the default value.

The PHP_IDE_CONFIG needs to have the same name as whatever you specify for your PHPStom server configuration, doesn't have to be lando.

@danharper83
Copy link

I've burnt a few hours trying to get this to work with no luck, what I find strange is that this all works with Drupal9 recipe following the lando documentation so why not adopt the same process?

If you add xdebug to platform.app.yaml wont't that run xdebug on the production dreployemnt and thus cause performance issues?

I'd got back to the Drupal9 recipe but I can't get the DB to export.

I'm mot sure what benefits the recipe has over the standard Drupal one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants