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
Please sign in to leave a comment.
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"
Missing/wrong path mappings is the most common reason.
P.S.
Check out this blog post (video!!): Webinar Recording: Debugging PHP with PhpStorm
what should go in the host textbox?
this is my config for the PHP > Servers window
https://www.evernote.com/shard/s3/sh/884414cc-4d19-4598-87b8-b8992e15ef37/17c9cab150d9fda7d04228c698ba2d1c
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).
this is what the zero config pops up
https://www.evernote.com/shard/s3/sh/f04d9da4-e335-49e1-9adf-d9e40bc5e0d8/177676a5042b09e9e5023728b7988cf3
or https://www.evernote.com/shard/s3/sh/f230077d-2660-48e0-83da-09d924d2c723/f24fdc1dc6c800707a85c14afcba441d
then when I go to Servers
https://www.evernote.com/shard/s3/sh/76999e55-ee1a-41d5-8896-3de78880c2e0/deedc2118cdc6426a6936e3155a77d3a
or
https://www.evernote.com/shard/s3/sh/4f372188-f811-4a43-930c-0bbc07e939ac/3fa10734f68c85dedd2ad46e4003d886
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):
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
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.
no value
looks like it has n value. I'll ask our server admin if he can fix this and get back to you
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;"
ok thanks
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)
woohoo! setting server_name to $host solves it for me, thanks for your help :)