12 Replies Last post: Aug 2, 2013 2:09 PM by paul de wouters  
paul de wouters Newbie 24 posts since
Apr 22, 2010
Currently Being Moderated

Jul 29, 2013 8:10 PM

Phpstorm server mappings with WordPress xdebug and vagrant

Hi

 

 

my dev environment consists of a vagrant box with a shared /projects folder on my local machine, and I develop WordPress sites

I have xdebug 2.2.3 which connects fine but has a strange behavior.

 

when I use zero config debugging, then I get prompted to select a file to debug, basically a list of all index.php files found in my project.

breakpoints don't work though. If I check the option to stop on first line of code, it does stop but it's not very useful becaues I want to inspect the vriables at the breaakpoint.

Basically I'm not sure how to configure the server folder mapping and make the debugging work properly.

 

thanks

Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Jul 30, 2013 2:54 PM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

Hi there,

 

You need to map remote location of your project to local location. The remote path should be real/resolved path, in case symbolic links are in use. This should be the path as xdebug sees it (which uses resolved paths).

 

In most cases you just map top level folders (e.g. C:\Projects\mysite.com --> /var/websites/mysite.com ) and the rest (sub-folders/files) will be calculated automatically (e.g. C:\Projects\mysite.com\app\functions.php --> /var/websites/mysite.com /app/functions.php ).

 

Path mappings can be set up at "Settings | PHP | Servers"

 

breakpoints don't work though.

Missing/wrong path mappings is the most common reason.

 

P.S.

Check out this blog post (video!!): Webinar Recording: Debugging PHP with PhpStorm

Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Aug 1, 2013 11:07 PM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

It should be your domain name (how you accessing it in a browser).

 

For http://backupwordpress.dev/index.php the host would be backupwordpress.dev

 

If you are using http://confluence.jetbrains.com/display/PhpStorm/Zero-configuration+Web+Application+Debugging+with+Xdebug+and+PhpStorm then this filed will be filled by IDE automatically (when it popping up asking you to match a file).

Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Aug 2, 2013 3:51 AM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

Well ... have not seen anything like that before (I mean -- empty host name) in my practice. Must be some specific configuration (OR .. quite likely, web server misconfiguration)...

 

1) What is the URL that you are using in a browser to access this site?

 

2) What is the value of $_SERVER["SERVER_NAME"] when you execute the script on this server using that URL?

 

3) What is the web server software (Apache/nginx/etc) ?

 

In your previous post, the absolute path on the server is WRONG (you have typed the same as local path). It should be (based on your new screenshots; double check the spelling, I typed from your pics):

  • Local: /Users/pauldewouters/hmn/projects/backupwordpress.dev
  • Remote: /srv/www/backupwordpress.dev
Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Aug 2, 2013 1:05 PM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

Thanks.

 

The host name on path mappings screen definitely should be "backupwordpress.dev".

 

If $_SERVER["SERVER_NAME"] is empty or looks like empty (which looks like it -- based on your screenshots; as PhpStorm is unable to fill this field automatically), then it's likely to be either web server misconfiguration (most likely) or it's manually overwritten in your code somewhere (which is rather unlikely and I have no clue why it should be done in first place).

 

If it's a nginx misconfiguration, then I will be unable to help you here -- I'm not familiar with it (never worked with it myself).

 

P.S.

If you have time -- see if you can setup another vagrant box with Apache as web server -- see if it will do any different.

Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Aug 2, 2013 1:47 PM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

Well .. for me it's clearly nginx config issue.

 

Have a look at http://wiki.nginx.org/PHPFcgiExample (or google for "nginx php" or somthing like that)

 

Instead of what advised there (fastcgi_param SERVER_NAME $server_name;) you (or admin) can try "fastcgi_param SERVER_NAME $host;" or maybe even  "fastcgi_param SERVER_NAME $http_host;"

Andriy Bazanov Master 4,088 posts since
May 28, 2010
Currently Being Moderated
Aug 2, 2013 1:50 PM in response to: paul de wouters
Re: Phpstorm server mappings with WordPress xdebug and vagrant

Yes, I've noticed that as well. See my updated previous post -- it has suggestions that I found by googling for "nginx php server_name" (first page of results)

More Like This

  • Retrieving data ...