hashbangcode / vlad

Vlad - Vagrant LAMP Ansible Drupal
173 stars 53 forks source link

Config change and documentation for debugging via Xdebug #99

Closed weitzman closed 9 years ago

weitzman commented 10 years ago

Vlad has good instructions for profiling (via Xdebug and XHProf) but cryptic instructions for debugging. It says To use the debugger, point your IDE at this box IP address ({{ boxipaddress }}) and use port 9000. I was unable to "point my IDE" at 192.168.100.100. Instead, I configured the VM to point to the host. My proposal:

  1. During setup, we set xdebug.remote_host=192.168.100.1 in php.ini. That instructs the Vagrant instance to contact the host in order to connect to a debug client. 192.168.100.1 is what my host shows for an IP. If this changes for other configs, we just have to put a hostname or IP for the host here.
  2. We add documentation to README.md:
    1. On the host, just start your debug Listener with default settings (Port 9000. IDEKey does not matter).
    2. Request any page with a querystring like http://www.drupal.local?XDEBUG_SESSION_START=foo. The value 'foo' does not matter - all values will cause PHP in the VM to connect to the host.
    3. When your IDE receives a connection from the VM, it should prompt you to create a Path Mapping. This helps your IDE pull up an editable file instead of a read-only copy thats provided by Xdebug.

We could add some pictures accompany these instructions.

philipnorton42 commented 10 years ago

Hi weitzman. Thanks for your suggestions and input over the past few days. I've been busy at work and conferences recently so I haven't had much time to look into the issues you've been having. I'll take a look at your issues as soon as I can, hopefully this week :) Thanks! Phil

philipnorton42 commented 9 years ago

Note to add these instructions to the documentation: http://vlad-docs.readthedocs.org/en/latest/applications/xdebug/

https://github.com/hashbangcode/vlad-docs/blob/master/applications/xdebug.md

kevinquillen commented 9 years ago

This is the way I do it - in my case I use PHPStorm, and I configure the debugging connection to point to the hostname. Works every time. I cannot speak for other IDEs, but PHPStorm is very well integrated with XDebug. You can add a IDEKEY, I tend to use PHPSTORM, and use the XDebug bookmarklets to trigger xdebug to start or stop.

https://www.jetbrains.com/phpstorm/marklets/

The only path mapping I need to do is telling PHPStorm where the docroot is on the VM, which is quite simple in Vlad (/var/www/site/sitename).

This setup literally takes less than 30 seconds and has always worked for me in PHPStorm.. I would expect a similar experience in Netbeans or Eclipse and other IDEs with a debugger config.

dixhuit commented 9 years ago

This is handy info, I think we should add this to the new docs. Thanks @kevinquillen !

[...] where the docroot is on the VM, which is quite simple in Vlad (/var/www/site/sitename).

Minor correction for anyone following along: the guest box's docroot is /var/www/site/docroot.

dixhuit commented 9 years ago

@kevinquillen Out of interest, how do you have your interpreter setup in PHPStorm for this? Do you use the "SSH Credentials" or "Vagrant" config option?

kevinquillen commented 9 years ago

I'll have to check.

On Saturday, February 21, 2015, Dan Bohea notifications@github.com wrote:

@kevinquillen https://github.com/kevinquillen Out of interest, how do you have your interpreter setup in PHPStorm for this? Do you use the "SSH Credentials" or "Vagrant" config option?

— Reply to this email directly or view it on GitHub https://github.com/hashbangcode/vlad/issues/99#issuecomment-75368660.

kevinquillen commented 9 years ago

My PHP interpreter I have set to 5.5 (the one that ships with OSX).

I have never utilized the Vagrant integration in PHPStorm yet, nor the SSH Terminal options. I used to use the built in terminal plugin, but found that there were some oddities in using it vs the Terminal app.

When configuring XDebug, PHPUnit or Behat debugger tools, I just point it to the hostname specified in Vlad, and the path mapping I set to /var/www/site/docroot. That has always worked for the debugger for me, no problem.

My site files (Drupal) reside on my local machine, while Vlad is hosting it on Apache.

philipnorton42 commented 9 years ago

All this has been added to the documentation, with a few extra details. Feel free to add more details via the docs repo here: https://github.com/hashbangcode/vlad-docs