I've done these steps:
Setup remote server for deployment in PhpStorm.
Setup docker server by SSH.
Setup file map.
Setup CLI Interpreter with remote docker.
Map port 9003 from container to remote host, and forward this port by SSH to localhost.
Issues:
"Run" test script not work with server + docker PhpStorm shows Could not open input file:/my/t.php message. I've tried changing path mapping to path/to/local/script, path/to/remote/script, path/to/docker/script and this did not do anything...
"Validate Xdebug" did not worked because this validator creates a test file, uploads it to the server and try run the script. But my server run scripts from directory /pub/ but if I set this directory for upload script, PhpStorm adding /pub/ to the URL http://test.remote/pub and get answer 404
I've tried to enable Listen for debug connection, enableed Xdebug extension in Google Chrome and set breakpoint on the first line, but connection was not established. Not working, I've checked 9003 port and it is allowed...
I've tried to create test.php to try debugging a CLI script, but this doesn't work too, see point 1 "run" not working.
Software versions:
PhpStorm - 2021.3
PHP - 7.4
Xdebug - 2.9.8
P.S. Sorry for my English.
P.P.S. I can't find manual how to setup PhpStorm, Xdebug with remote server in docker ((
Related
I'm trying to make this setup work with no success for debugging. I have this Xdebug configuration in a Vagrant box with PHP 8 but I can't debug with Eclipse PDT... Can anybody help or point to the right direction?
The solution was setup xdebug.clienthost to my Windows Machine local network, where eclipse is installed. So I did vagrant ssh, then edit the 20-xdebug.ini located at
/etc/php(the version you are using)/fpm/conf.d and added the line
xdebug.client_host =192.168.1.49
notice that your xdebug.client_port must be 9003 also
of course this is my ip of my laptop in my local network you have to figure out yours and make it fixed if you are behind a dhcp router.
Then I did a vagrant reload.
Then in Eclipse I setup the xdebug preferences to listen the 9003 port, stop the first line and prompt for remote connection.
And in firefox I installed the xdebug helper and choose "debug" before loading the page.
Not sure how to configure the pathMappings in the VSCode debug config when I open a remote directory on a Linux webserver from a Windows machine using the VSCode Remote Explorer SSH plugin. If I store a copy of source locally and initiate VSCode with local source the debugging works fine.
Web server is Ubuntu 14 Lamp, local system is Windows 10. Using Remote Explorer plugins in VSCode to ssh into Linux server from Windows workstation and edit source on server.
This works fine in VSCode debug config when I have source files stored locally and initiate VSCode by opening my local copies.
pathMappings": {
"/var/www/html/codeigniter/": "${workspaceRoot}",
},
When I initiate VSCode on Windows by using the Remote Explorer, this config does not work. I connect via remote explorer to this root folder /var/www/html/codeigniter/
I expect to have the breakpoints recognized and stop the code when I open the files on the Linux server via the SSH plugin for VSCode, but they are not and the code runs without hitting breakpoints.
Thanks for the reply. I wanted to avoid having a copy of my code so I can edit as I debug.
I did end up getting things working. So I can use the VSCODE ssh connect and then debug and edit source on the server without making a local copy.
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 9000
on my linux server my xdebug settings
xdebug.remote_handler=dbgp
xdebug.remote_log="/tmp/xdebug/log"
xdebug.profiler_enable = 1
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.remote_host = 127.0.0.1
I had to set remote_host to the localhost, then everything worked.
I didn't understand xdebug enough to realize that remote_host would need to be set even if the IDE debugger is running on the same host . I also didn't understand enough about vscode to realize when in SSH remote edit mode, the debug component is actually installed on the remote server making it a localhost connection between xdebug and remote host.
anyway, issue resolved. Thanks for the answers, that helped me on my path.
As Cris said you should remove xdebug.remote_connect_back=1 in php.ini
I have a remote machine where runs an Apache Server. I want to use Xdebug on my local machine, using PhpStorm, to debug the PHP files located in my remote server.
Here is what I did on my remote Ubuntu server :
1. apt-get install php7.2-xdebug
2. Go to /etc/php/7.2/apache2/php.ini and add :
[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable=1
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_host=<my local machine IP without braces>
xdebug.remote_log="/var/log/xdebug.log"
xdebug.idekey=PHPSTORM
3. Restart Apache server /etc/init.d/apache2 restart
4. When I create a script with echo phpinfo(); in it, it shows that Xdebug has been installed "correctly" (I guess) : it shows an Xdebug section with all the variables.
5. In PhpStorm, I set a breakpoint on a file, and I start listening to incoming debug sessions, I verify this by doing a netstat query that returns that my Mac has its process PhpStorm listening to port 9000
6. In Chrome browser, I download the extension Xdebug, and I open my script, where I added the breakpoint. The mapping between this file that I open in Chrome and the local files is correct.
7. I tap the button "debug" in the Chrome extension, it becomes green. I verified, the cookie is correctly sent as http headers has XDEBUG_SESSION=PHPSTORM
Despite all of this, I cant achieve to have any incoming session on PhpStorm.
I tried to see file /var/log/xdebug.log that I registered to be the log file of Xdebug, but this file is empty....
Did I forget something ? I have no idea what to do its been 8 hours I'm on it I have seen all post related to it on StackOverflow but nothing worked for me (I can't even manage to have something in /var/log/xdebug.log so I could see deeper what's going on). I have no idea if Xdebug is doing something when it receive my HTTP request.
you phpstorm'configure is maybe error.
I have a problem to debug php files with Aptana Studio. I don't know is it possible to be done because the way of working is a little bit complicated.
Actually I have my source PHP files into my local Windows machine, also my Aptana studio. The Apache server has been installed on the Ubuntu virtual machine and has as source the files of my local Windows machine.
From the web browser into my local Windows I charge the URL of the virtual machine and I would like to debug from Eclipse/Aptana.
I have to configure Xdebug in Eclipse, but I don't find issues how to do in my case.
Is there someone having the same problem or idea ?
Finaly we found the solution for Eclipse PDT but the same is valid for Aptana just the eclipse configurations are a little bit different.
In order to implements the remote debug you must to install the xdebug packages where the virtual machine is (in our case the Ubuntu virtual machine).
After into the /etc/php/7.0/mods-available/xdebug.ini you must to configure the 2 lines :
xdebug.remote_enable=on
xdebug.remote_host=192.X.XX
where the remote_host is the IP of your local machine containg the eclipse.
Further you must to change the eclipse configuration Windows->Preference->PHP->Debug->Debuggers->Xdebug to put the debug port (same as in xdebug.ini file - default 9000), and set Accept remote session (JIT) to any.
For Aptana change the xdebug configuration by searching where Accept remote session (JIT) is.
I'm trying to use XDebug in the following scenario
Physical Host on Windows 7, with Netbeans 7.1.1
Virtual guest on Ubuntu, with Apache server and PHP 5.3.10
the PHP code of my website is on a shared folder on Ubuntu, in /var/www/mysite
the PHP code is accessible from my Windows host, on \\guestIP\mysite, with R/W permissions
Website accessible from http://mysite.local.fr, from both host and guest
I created a Netbeans project from my Windows Host, pointing to \\guestIP\mysite.
In the project Run configuration, I have the following:
Run as: Local web server
Project URL: http://mysite.local.fr
Index file: index.php (does exist in the project)
In the Advanced Run Configuration:
I checked "Ask every time" (I also tried using "Do not ask" and starting the browser with the session key myself)
I tried setting '/var/www/mysite' - \\GuestIP\mysite for the mapping (and tried using nothing as well)
I haven't touched the proxy settings
I have the following in the php.ini on my Ubuntu VM
xdebug.remote_enable = on
xdebug.profiler_enable = off
xdebug.profiler_enable_trigger = off
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir = /tmp
;xdebug.remote_host=localhost,<HostIP>, mysite.local.fr
xdebug.remote_connect_back=1
xdebug.remote_handler=dbgp
xdebug.idekey="netbeans-xdebug"
xdebug.remote_mode=req
None of this works, Netbeans does not stop at any breakpoint from Windows.
Debugging directly from my VM with Netbeans works fine.
Can someone tell me how to get my debugger to work remotely from Windows?
Thanks
Sorry, i can't comment anymore. #David #JamesB41: I've been looking for this too. My setup is a Windows 7 host with NetBeans 7.1, and an Ubuntu VM in VirtualBox. I have the NetBeans project set up as a remote project, uploading and downloading using SFTP.
The following setup works for me, just use your host's IP as remote_host, and make sure the VM can see it.
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_host=10.217.165.193
xdebug.remote_port=9000
xdebug.remote_log="/tmp/log/xdebug.log"
NetBeans will stop at the entry point breakpoint (if you have the option set in PHP->Debugging). But, it won't stop on NetBeans-created breakpoints, because its running off the VM's files. You can use xdebug_break() though, and it will show stack and variables. It will stop at NetBeans breakpoints and highlight if you map the folders correctly in project config > Run Config > Advanced. Awesome. I am complete.
(The connect_back config didn't seem to help, possibly because $_SERVER['REMOTE_ADDR'] isn't populated.)
Go through the below document for remote debugging using NetBeans. Very helpful.
http://stuporglue.org/setting-up-xdebug-with-netbeans-on-windows-with-a-remote-apache-server/
In know this is old but a good reminder. Make sure if you are using nat in virtualbox that you set port forwarding on the xdebug port back to the local machine typically 9000 by default.
Another option is to have the VM configured to speak to its own localhost:9000 (default for xdebug) and then ssh in from host to VM and establish a port tunnel for that port back to the host machine. Then your host machine debugger simply connects to localhost:9000 and everything should work exactly as if they were running on the same machine.
See: Multiple users XDebug and PHP Debugging
Debugging remotely with Linux + Apache + PHP + xdebug + NetBeans (SFTP)
I've got the following setup and it works.
Host PC (client)
Linux Debian Jessie **
NetBeans version 8.0.2
NetBeans has a project created as "PHP Application from Remote
Server", that has to be debugged
NetBeans connects to Remote Server using SFTP
IP (for example): 192.168.0.2
** I am aware that the OP question mentions Windows, but regarding that the main setup to solve this should be made on the VM, I hope this helps somebody anyway.
Guest PC (server) / Virtual Machine
Linux Debian Jessie
Apache
PHP 5.6
xdebug 2.2.5
IP (for example): 192.168.0.1
The following steps should be made on the "Guest PC (server) / Virtual Machine"
install xdebug sudo apt-get install php5-xdebug
edit /etc/php5/apache2/php.ini,
add these lines right before the [Date] AND change xdebug.remote_host to reflect your "Host PC (client)" IP:
[debug]
; Remote settings
xdebug.remote_autostart=off
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_host=192.168.0.2
xdebug.remote_port=9000
restart apache sudo service apache2 restart
Reference
How to configure XDebug - Remote Debuging http://wiki.netbeans.org/HowToConfigureXDebug#Remote_Debuging
you need to have correctly configured property xdebug_remote.host on
remote machine. The IP address of local machine has to be defined in
this property. For example, you want to debug your source code on
remote machine 192.168.0.1 using Netbeans installed on 192.168.0.2.
You need to change xdebug.remote_host on 192.168.0.1 to
xdebug.remote_host=192.168.0.2. If doesn't work verify you have port
configured in xdebug.remote_port open on both machines.
If all seems to be correct but you still get "Waiting For Connection" from inside netbeans you should try in your php.ini settings
xdebug.remote_connect_back=on
as it allows connection from ANY ip or look at a lot more info on the issue http://www.devside.net/wamp-server/netbeans-waiting-for-connection-netbeans-xdebug-issue