I can't seem to use xdebug in PHPStorm when running a local server. The server document root is the direct parent of the PHPStorm project root and I can run the project on a web browser and through the "Tools | Test RESTful Web Server" option.
I:
am running my Apache server on a mac (OSX 10.10.5) and used brew to install php 5.5 and xdebug 2.3.3 (which was honestly a huge hassle, as nothing wanted to work). The xdebug shows up properly in my phpinfo() and when I use the terminal command $ php -i so I think it is installed correctly.
have followed several guides, tutorials, and SO questions that either do not pertain to my situation and/or their answers were non-working or absent
Configuring Xdebug (PHPStorm) and may more from the PHPStorm website...
Connection Between PHP and Xdebug (SO) this one was the closest I could find to my situation and it did not resolve my issue either. All the other ones I could find were not very helpful because they were working with the MAMP stack.
can't validate my xdebug with PHPStorm in "Run | Web Server Debug Validation". Everytime I try, no matter how I fiddle with the settings, it is either a connection refused error (which I believe is because I am trying unopened ports) or this:
Web Server Debug Validation returns unexpected format error.
Both the bookmarklets that XDebugger supplies on their website and the browser extensions fail as well.
The weird thing to me is, if I create a virtual host in the apache httpd.conf with the servername as my external IP address and with the same document root, I can access it (not the weird part) but I can also run the debugger perfectly fine through it. This is undesirable as it seems that anyone can now run my code and receive responses with sensitive information. They might also be able to start my debugger, but that would be more of an annoyance if they could.
I have been able to, up until this point, work without a debugger, but there have been instances where it would have been great to have one. Looking toward the future I can say for certain that having a debugger will help immensely with my projects, so any help would be greatly appreciated.
I would also prefer not to reinstall everything as it was a huge pain to set it all up in the first place, but if it's a last resort I may have to.
I can provide more information if needed.
Thanks,
Jacob
I managed to get the step debugging to work with a couple changes:
For the validation test, instead of just localhost I attempted to validate a sub-folder that contains my code for the project. The PHPStorm project itself was set to this folder. I think that because my document root was outside of the project that it refused to validate the xdebug extension.
I also configured my DBGp Proxy under Tools to accept the IDE key that xdebug had set as default and updated the IDE key in the xdebug bookmarks.
I can now step debug with Run > Start Listening for PHP Debug Connections and in-browser using the XDebug Debugger bookmarks.
Jacob
In addition to the accepted answer, you need to download and run the debug proxy on the server itself
Download an install the Python Remote Debugging package from Komodo (http://code.activestate.com/komodo/remotedebugging/)
Start the DBGp proxy on the web server.
In PHPStorm, start listening for the debugger: "Run | Start Listening for PHP Debug Connections" (You may need to register the debug server: "Tools | DBGp Proxy | Register IDE")
Jet Brains how-to: https://confluence.jetbrains.com/display/PhpStorm/Multi-user+debugging+in+PhpStorm+with+Xdebug+and+DBGp+proxy#Multi-userdebugginginPhpStormwithXdebugandDBGpproxy-2.DBGpproxy
None of the suggestions worked for me, so I kept digging.
Even though IPV6 was disabled on my network adapter, it is still a preference on the loopback adapter.
A ping localhost would result in Reply from ::1: time<1ms
I've fixed this by preferring IPV4 over IPV6 in the Windows registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\TCPIP6\Parameters
Set DisabledComponents to Hex 0x20 or decimal 32.
Now ping localhost comes back as Reply from 127.0.0.1: bytes=32 time<1ms TTL=128 and the debugger validation works fine.
Related
I am a big proponent of Xdebug and love PhpStorm. I have worked with many different setups for local environments and configuration seems to be a bit different each time.
My current environment is a docker container running on my local machine. I understand that PhpStorm is listening to 0.0.0.0, aka - to all network interfaces, and on a specified port (I'm using 9004). I also see that I can ping my local machine from the docker container hosting Xdebug.
What I don't understand is: when I put a breakpoint in PhpStorm, how does Xdebug know that it exists, so that when it hits that line of execution it should tell PhpStorm to stop?
When Xdebug first connects to the IDE, the IDE sends over a list of breakpoints that it wants Xdebug to interrupt PHP at. If you have a look at a log file (made with xdebug.log=/tmp/xdebug.log), then you will see commands being send starting with breakpoint_set. There is then a type (-t), often line for a file/line breakpoint, as well as the file name and line number.
When PHP runs code, Xdebug intercepts the execution, and when it sees a match filename/line number combination, it pauses the execution and goes into command mode so that the IDE can send commands to inspect the current scope (by sending content_get) as well as further information about variables (with property_get). Then when you click "Continue" or "Step Over", the IDE sends a command to Xdebug to do the equivalent action.
To see a full description of the protocol, give the DBGp protocol specification a read.
I have trying to get this done for days...and reading through about 20 tutorials, documents, etc...but still no luck.
Here is the thing. I installed wordpress(just for example, can be any php program) on my VPS, and hoping to debug it from my macbook and my desktop. This is clearly a remote debugging thing. So I here is what I done:
1.Installed right version of xdebug and located its .so file on VPS.
2.Changing php.ini and 20-xdebug.ini file on VPS, my settings currently are:
zend_extension=/usr/lib/php5/20131226/xdebug.so
xdebug.remote_enable=1
xdebug.remote_connect_back=1
xdebug.remote_port=9200
xdebug.show_local_vars=0
xdebug.var_display_max_data=10000
xdebug.var_display_max_depth=20
xdebug.show_exception_trace=0
xdebug.remote_log=/var/log/xdebug.log
;xdebug.remote_host=202.84.93.66
The last line, which is comment out is my desktop IP address, where I run phpStorm. Based on xdebug's documents, if you set remote_connect_back=1, you won't need this host ip to be specifici.
On phpStorm Side, I "start new project from existing code, and specificy the source root on VPS, map it with one of my local dest. PhpStorm just downloaded all the files and after setting up "Automatic upload", the sync is perfect.
On phpStorm side, I specificy the PHP intercepter as the remote one on my VPS.
On phpStorm side, I changed my debugging port to 9200, as same as the one I using on VPS.
Using the booklet method phpStorm provide, I put them on my firefox bootkmarklet.
Click listen button on phpStorm, set breakpoint, go to firefox open the page, click 'start debuging', refresh.....BUT NOTHING HAPPENS!
I also tried to using the tranditional methods, which set a run configration way as both php-webapplication or php-remote-debug...but still not working.
At php storm, the web debug validation, I could pass all the testing there though....
Can anyone help me with this? I think I must be doing wrong on some very fundation part since I saw all the tutorial are so simple set, but this already took me about 3 days to figure out....
Thanks!
I've seen other questions/answer about this topic but none of them seem to have the same issue I have, so here we go:
What I'm trying
I'm using phpStorm 8 to develop PHP websites (CakePHP 2.5.1 in this specific case). I have a copy of the website on my computer, make whatever changes there and upload the new version to the production server via the integrated FTP tool. So far all pretty simple, no issues at all.
Now I would like to start using Xdebug to debug the websites using the production server (PHP 5.3.28), so I'm trying to set up remote debugging with phpStorm and Xdebug.
What I have done so far
I have installed Xdebug 2.1.3 on the production server, and it seems to be working. To test that I've done whats recommended in this other SO question, and all those things work.
This is how the config in php.ini looks like:
zend_extension="/usr/local/src/xdebug-2.1.0/modules/xdebug.so"
xdebug.profiler_enable='0'
xdebug.profiler_enable_trigger='1'
xdebug.profiler_output_dir='/home/username/debug'
xdebug.remote_enable='1'
xdebug.remote_connect_back ='1'
I'm not setting the remote_port variable because I'm fine with the default port (9000). Also, I'm not setting the remote_host IP because I'm using the remote_connect_back option to allow multiple IPs, as explained here.
I've also tried 2 different approaches to set all this up:
I followed this Zero Configuration tutorial, but at step 7 I never get the Incoming Connection dialog.
I also followed this different tutorial but in the Integrating XDebug with PhpStorm step I don't have the choose XDebug from the Debugger drop-down list option on step 3
What I need
If someone could help me figure out what I'm missing or doing wrong that would be great!
I would have added this to the comments, but don't have the needed rep.
Have you set the preferences correctly in your project? Were you able to configure and validate your deployment server (under Deployment)?
After that, set up the server under PHP > Server and validate it as well.
Don't forget to check the firewall on your host.
Make sure that you can get XDebug working without PHPStorm, then circle back around and integrate it.
These are the php.ini settings, other than the driver path, that I am using for my CLI project:
xdebug.remote_enable = 1
xdebug.remote_connect_back = 1
xdebug.remote_autostart = 1
xdebug.remote_host = 192.168.100.1
Most importantly, listen to LazyOne. Specify your remote host. And don't run debuggers on your production gear. Spend some time learning about Virtual Machines. My recommendation is to check out VirtualBox, Vagrant, and SaltStack. Used together, these tools will allow you to debug your code in an environment that is as close to production as possible without adding the burdens and risks involved with your debugging tools.
I was able to successfully install both Zend as well as Xdebugger. Verified by Phpinfo as well as Eclipse verifies the Zend debug successfully installed. Although whenever I run debug from eclipse for
Xdebug it hangs at 57%`
and for Zend debugger
the browser keeps processing/busy but nothing happens
Unsure what is causing this
-> Firewall issues?
-> No Selinux in Mac so not sure if it is a permissions issue
Any clues would be helpful.
Thank you.
it seems like a miss configuration of debug. I will try to help you showing my working configurations.
This is my php.ini piece for xdebug.
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable=On
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9060
xdebug.remote_handler="dbgp"
xdebug.remote_autostart=On
It is important to note about the parameter debug.remote_host. If your client side is not allowed here, you will stuck on 57%. The value here is the IP of the machine where you are running eclipse. If you are running apache/php and eclipse in the same machine the localhost IP should work.
Adapt zend_extension parameter to your world.
Other reason you can stop in 57% is the web site is not running. Apache/PHP only will send xdebug metadata if the site is running. If you got an internal error, for example, you will be stuck on 57% also. Eclipse stops on 57% waiting for a xdebug session. You must be sure apache/php started a debug session.
Make sure the Debug configuration on eclipse is using the correct PHP server. If you are trying to run eclipse in an invalid PHP server or a PHP server which is not well configured you will stop on 57% also. So review the PHP server parameters on Debug Configurations.
Other important review you have to made is about the Xdebug configuration for eclipse. The port Debug port field must be filled with the same value of parameter xdebug.remote_port. If they are different you will be stuck in 57% also.
Please, let me know if it was helpful.
For Xdebug, this is likely a misconfigured path mapping in Eclipse. There are 10s of questions related to that here on stackoverflow and 100s of hits on google. Please check there first.
I've using Netbeans to develop on a windows machine, the files I'm editing are on a remote LAMP server. The document root is mounted on my windows machine as a drive letter (Y:). So, netbeans things I'm developing locally, whereas I'm actually developing remotely on a local mount.
My problem starts when I want to use xdebug and netbeans to debug CLI PHP scripts. Debugging browser based stuff is fairly straight forward, but debugging CLI stuff is a little more convoluted and I'm not sure I know how to get it working.
The first problem is that, Netbeans wants to know where the php5 interpreter is, but I can't tell it as it's on the remote server...
Does anyone have any experience with doing this?
Thanks,
Mike
The key Netbeans PHP debugging breakthrough came for me when I added a path mapping to my project (under Project Tab|Right-click Project|Properties|Run Configuration|Advanced Button), so that my project knew how to correlate server source code paths to the local paths (windows drive letter paths).
Example path map:
/home/myusername/sourcedir mapped to x:\sourcedir
I believe I work with a similar configuration to yours (LAMP server, windows machine with the source from the LAMP machine showing up locally under a windows mapped drive). This worked for me.
I had been trying the URLs for my project (http://server/projectroot) as the path mapping. That was not what was needed. The actual path on the server (i.e. my home directory and below) was needed.
Pada meant: xdebug.remote_connect_back, not xdebug.remote_enable. You must have both of them set in order for Xdebug to auto-connect back to Netbeans (or whatever the debugger).
The xdebug.remote_host variable refers to the host that xdebug should connect. You can debug PHP on a remote server using NetBeans, but it would require you to configure xdebug on the remote server such that it would connect to your development PC.
Here's a simple example:
Your development PC, with NetBeans, is on 10.0.0.100,
and your remote PHP webserver is on 10.0.0.1
Set the xdebug.remote_host=10.0.0.100
Now whenever someone (or you) specified the XDEBUG_SESSION_START parameter in the URL on the remote server, xdebug would try to connect to 10.0.0.100.
Xdebug v2.1 has a nice feature: xdebug.remote_enable = 1
Enabling that option would override xdebug.remote_host and then xdebug would connect to the $_SERVER['REMOTE_ADDR'] (which is the IP address that the client is connecting from). This awesome feature would allow you to have multiple debugging on the same server, since you can't manipulate xdebug.remote_host with ini_set()
I don't know about Netbeans, never used it, but in Eclipse PDT where you can also debug using XDebug there is a distinction between "PHP web page" and "PHP script". For "PHP web page" you choose a web server (that you configured earlier) and not a php interpreter (like you have to do with "PHP script").
Perhaps there's the same thing for Netbeans?
xdebug.remote_autostart=1 to automatic remote connection.
in "Xdebug v2.1 has a nice feature:".