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

12 comments

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

0

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).

0

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
0

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

http://backupwodpress.dev

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

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

nginx

0

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.

0
_SERVER["SERVER_NAME"]

no value



looks like it has n value. I'll ask our server admin if he can fix this and get back to you

0

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;"

0

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)

0

woohoo! setting server_name to $host solves it for me, thanks for your help :)

1

Please sign in to leave a comment.