XDebug only works on localhost and not remote host - php

I've installed xdebug on my raspberry pi with visual studio code and everything is working except that I can't use xdebug with a remote host.
In php.ini and xdebug.ini and php.ini I have xdebug.remote_connect_back = 1 however whenever I load the page from my personal computer I just get listening for xdebug in vs code.
this is my configuration in php.ini
[Xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
and this is my configuration in xdebug.ini
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_handler = dbgp
xdebug.remote_connect_back = 1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000
It should work when I open the webpage on my computer but nothing happens. And there isn't even a log file in /tmp/.

Related

NetBeans 11.3 waiting for connection to Xdebug

I am using Windows 10, NetBeans 11.3, PHP7.4.9, Apache/2.4.46 (Win64), XAMPP v3.2.4 and MySQL.
My php.ini file has the following settings:
output_buffering=off
[XDebug]
zend_extension = "c:\xampp\php\ext\php_xdebug-2.9.7-7.4-vc15-x86_64.dll"
xdebug.remote_autostart = 1
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "c:\xampp\tmp"
xdebug.remote_enable = 1
xdebug.idekey="netbeans-xdebug"
xdebug.remote_handler = "dbgp"
xdebug.remote_host = "localhost:81"
xdebug.remote_log = "c:\xampp\tmp\xdebug.txt"
xdebug.remote_port = 9000
xdebug.trace_output_dir = "c:\xampp\tmp"
xdebug.remote_cookie_expire_time = 36000
NetBeans configuration:
Debugger port: 9000
Session ID: netbeans-xdebug
Stop at first line: Checked
All other options are unchecked
When I click on debugging icon (Ctrl + F5) it gets stuck on "waiting for connection (netbeans-xdebug)" while shows the page completely without stopping at the break points.
xdebug.remote_host = "localhost:81" is certainly not correct. The remote_host should have the value of the IP address or hostname where your IDE runs. This is likely just localhost.
You should also upgrade to Xdebug 3.1, which has much better logging functionality for troubleshooting connection errors through it's xdebug_info() function, and xdebug.log and xdebug.log_level settings.
Please do refer to the upgrade guide though, as some setting names have changed. You would likely only need:
zend_extension = "c:\xampp\php\ext\php_xdebug-3.1.3-7.4-vc15-x86_64.dll"
xdebug.mode=develop,debug # replacement for xdebug.remote_enable
xdebug.start_with_request=1 # replacement for xdebug.remote_autostart
xdebug.idekey="netbeans-xdebug"
xdebug.client_port = 9000 # replacement for xdebug.remote_port
# I would recommend to use the default 9003,
# but you need to update Netbeans config to
# say the same too.

PhpStorm Xdebug multiple users same session remotely on Ubuntu

zend_extension=xdebug.so
xdebug.remote_enable = 1
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
xdebug.show_error_trace = 1
xdebug.remote_autostart = 1
xdebug.mode = debug
xdebug.discover_client_host = 1
xdebug.start_with_request = yes
The problem is the Session ID. It seems like its the same on for all users.
We use the Xdebug browser extension and listen in PhpStorm for incoming connections. No other settings.

Xdebug won't run on local website in NetBeans

I've created a PHP project in NetBeans called TerraNubis. The project folder and source folder are located in C:\development\TerraNubis. In the Project Properties window, in the Run Configuration tab I've set the option to run the configuration as local website, the project url to http://localhost/TerraNubis/ and the index file to index.php.
I installed XAMPP (xampp-win32-7.1.11-0-VC14-installer.exe on Windows 10) and downloaded Xdebug (php_xdebug-2.5.5-7.1-vc14.dll, which is now located in C:\xampp\php\ext).
The files from the sources folder are being copied to C:\xampp\htdocs\TerraNubis. In the NetBeans Options window I've set the PHP 5 interpreter to C:\xampp\php\php.exe. In the Debugging tab, the debugger port is set to 9000, the session ID to netbeans-xdebug and the maximum data length to 2048. All the checkboxes in this tab are empty.
In my php.ini file I commented out
zend.enable_gc = On
and at the bottom of the file I added the following code:
[XDEBUG]
zend_extension = "C:\xampp\php\ext\php_xdebug-2.5.5-7.1-vc14.dll"
xdebug.idekey = netbeans-xdebug
xdebug.profiler_append = 0
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_dir = "C:/xampp/tmp/xdebug"
xdebug.profiler_output_name = "cachegrind.out.%t-%s"
xdebug.remote_enable = 1
xdebug.remote_autostart = 0
xdebug.remote_connect_back = 0
xdebug.remote_host = "127.0.0.1"
xdebug.remote_port = 9000
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = req
xdebug.remote_log = "C:/xampp/tmp/xdebug/xdebug_remot.log"
xdebug.show_local_vars = 9
xdebug.trace_output_dir = "C:/xampp/tmp"
In NetBeans, when I right click on the TerraNubis project in the Projects tree and click on Debug, I see at the bottom right the message: "Waiting For Connection (netbeans-xdebug)". Then nothing happens. It just keeps displaying the same message.
How can I run the Xdebug properly on a local website?

It is possible avoid only external connections to my xdebug with Ngnix and PHPStorm?

I have a development environment in my computer, I use nginx and PHPStorm with Xdebug for my debugging, I need to debug in my environment but other people also connects to my machine for testing purpose, it is possible that when I active my debug this only affect me and not for they?
Update:
My xdebug.ini looks like this:
zend_extension=/usr/lib/php5/20090626/xdebug.so
xdebug.idekey = PHPSTORM
xdebug.remote_log = /tmp/xdebug.log
xdebug.remote_enable = 1
xdebug.remote_connect_back = 0
xdebug.remote_handler = dbgp
xdebug.remote_port = 9001
xdebug.remote_autostart = On
xdebug.profiler_enable = 1
xdebug.profiler_output_dir = /tmp
xdebug.remote_host = localhost
The key here is the setting: xdebug.remote_host. The default value is localhost, which guarantees that Xdebug only contact a debug client which is listening on your localhost and configured port
More detail: Xdebug Settings Document
& Remote Debugging Document

PhpStorm XDebug with a remote browser

I have debugging enabled from my localhost - RHEL. So my phpstorm installed on localhost works fine when i request a url from the same box as the apache server.
However, I would like the debugging to work from another machine (different host). Is there a setting that i am missing to enable. that.
my ini file :
zend_extension = ${extension_dir}/xdebug.so
xdebug.profiler_append = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_aggregate = 0
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = /tmp
xdebug.profiler_output_name = cachegrind.out.%p
xdebug.remote_enable=On
xdebug.remote_handler=dbgp
xdebug.remote_host =localhost
xdebug.remote_port = 9000
xdebug.remote_mode = "req"
xdebug.allowed_clients = ""
xdebug.remote_connect_back=1
xdebug.idekey="mykey"

Categories