Eclipse stops at 57% when launching Xdebug debugging session - php

Debugging using Eclipse and XDebug has worked fine on my workstation for a long time and suddenly it stopped. It freezes at 57% saying: "Launching: waiting for XDebug session".
I checked similar questions: here, here, here, here, here, here and here.
I have a following configuration:
Host: Ubuntu 14.10, Eclipse Luna
Server: CentOS 6.5 with PHP 5.6.6 and Apache 2.2.15 running as VM on VitualBox in network bridge mode
XDebug settings in Eclipse
XDebug server configuration (/etc/php.d/15-xdebug.ini):
; Enable xdebug extension module
zend_extension=xdebug.so
; see http://xdebug.org/docs/all_settings
xdebug.remote_enable = On
xdebug.remote_mode = req
;xdebug.remote_host = 192.168.100.4
xdebug.remote_connect_back = On
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.remote_autostart = Off
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.profiler_enable = Off
xdebug.profiler_output_dir = /media/sf_proofhq/web2/log/profiler
xdebug.profiler_output_name = %s%R.cachegrind
xdebug.max_nesting_level = 1000
I have tried the following:
disable remote_connect_back and enable remote_host
upgrade PHP (from 5.5.4 to 5.6.6)
change port from 9000 to 9001 or 9900
restart host, VM/server and Eclipse
check XDebug logs
switch VM network settings to NAT & Host only
Nothing has helped. :-(

I have found a workaround: create a new Virtual Host and new Eclipse Workspace.
UPDATE:
If Eclipse keeps breaking at first line, then do this.

Related

How to use visual studio 19 to debug a php app running on an azure Ubuntu VM

I’ve configured the virtual machine, installed apache2, php, MySQL and xdebug. The website works and I’ve configured VS but nothing happens when I debug the project in VS.
Note I have to use a VM because there is some trickery that is being done with open VPN.
I am no expert with PHP as I come from the ASP.NET world and I have never used Xdebug before.
I've been asked to add some additional information but the /etc/php/7.2/apache2/php.ini file is too large to add into this post. If you want some more information please ask for a section and I will post it.
In the mods-available folder is an xdebug.ini file that contains:
zend_extension=xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 127.0.0.1
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
I've also set up an inbound rule in Azure for the server to a allow port 9000.
When running VS I have set up the Server URL and specified Xdebug Port 9000.
DBGp proxy is not set.
Thank you
Tim
I finally managed to get something to work.
I updated the xdebug.ini like this:
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 1
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = 86.180.220.70
xdebug.remote_log = /tmp/xdebug_remote.log
xdebug.remote_mode = req
xdebug.remote_port = 9000 #if you want to change the port you can change
xdebug.idekey = "php-vs"
And, crucially, opened the firewall on my machine for port 9000.
Now I can't seem to set any break points in php that actually hit.
I'm assuming this has something to do with path mapping - plenty of stuff on google for Code but little if nothing for Visual Studio...
I have to say the documentation for doing things like this is SHOCKINGLY bad. Most examples are for a Windows php.ini file, not for Linux. If your a seasoned php programmer your probably used to it but for a newbie like me its an absolute minefield.

Debugging PHP, from NetBeans using XDebug and XAMPP

I have followed this document:
This is my php.ini
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9000
I am running Apache using XAMPP on port 9000:
from NetBeans when I do: Debug -> Debug Project
I get the following:
Port 9,000 is already in occupied. Configure the IDE to use another
port?
XAMPP is the software that is using port 9000 thousand. What do I need to do here? Should I change the XDebug port to 9001? Tools -> Options:
If I do this, I would also need to change php.ini and change the XDebug port to 9001.
Or should I keep using port 9000? I have been different settings, but not able to hit my break point.
I have been using Netbeans for years to code PHP and xdebug has always been a pain. I cant even give you any pointers.
But I switched last year to VS code and I can honestly say that it improved my code, and xdebug is actually easy to connect, and fun to use.
I recommend you give it a try.
This is how I got the debugger running:
When prompted with:
Port 9,000 is already occupied Configure the IDE to use another port?
Click Yes (alternatively you can open the setting from Tools -> Options: Choose PHP -> Debugging)
Set debugger Port to 9001.
update php.ini to have port 9001
[XDebug]
zend_extension="C:\xampp\php\ext\php_xdebug.dll"
xdebug.profiler_enable = 1
xdebug.profiler_enable_trigger = 1
xdebug.remote_enable = 1
xdebug.remote_host = "localhost"
xdebug.remote_handler = "dbgp"
xdebug.remote_mode = "req"
xdebug.remote_port = 9001
Restart XAMPP

PhpStorm Docker & zero-configuration Xdebug

I am trying to set a zero-configuration debugging for PhpStorm/Docker/Xdebug.
Xdebug is installed properly (I can see it loaded on phpinfo()):
My PhpStorm setup for debugging is standard, listening on port 9000. Here is the xdebug config I'm using:
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20190902/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_handler = dbgp
xdebug.remote_host = docker.for.mac.localhost
xdebug.remote_port = 9000
xdebug.remote_autostart = 1
xdebug.remote_connect_back = 0
xdebug.remote_log = /var/log/xdebug.log
xdebug.idekey = "PHPSTORM"
Off topic: I am also wondering if using xdebug.idekey is the same as providing IDE key through Chrome extension?
When I click on PhpStorm to start listening for connections, and set in the configuration to break on first line, I am getting the following:
Looking at Xdebug logs, it is clear that container connected to client (which is also clear from the fact that I am getting an error when trying to debug).
At this point, I have no manual servers or remote debug configurations set up.
If I define a server and remote debug configuration, and set environment key:
environment:
- PHP_IDE_CONFIG="serverName=docker-server"
And then if I click to debug:
Debugging then works, and no errors appear.
But this is then not a zero-configuration debugging...
What am I doing wrong?

Xdebug connection not working with PhpStorm and Docker

I have a problem debugging PHP with PhpStorm. I have container, and it is running Ubuntu 18.04.2 LTS and my host machine is macOS 10.14.5. I added configuration to PhpStorm, but breakpoint is not hit.
So, this is my xdebug.ini configuration:
zend_extension=xdebug.so
xdebug.max_nesting_level = 250
xdebug.remote_port = 9000
xdebug.idekey = "XDEBUG_ECLIPSE"
xdebug.remote_host = "192.168.1.144"
xdebug.var_display_max_children = -1
xdebug.var_display_max_data = -1
xdebug.var_display_max_depth = -1
# Enable the debugging on request
xdebug.remote_enable = on
xdebug.remote_autostart = off
# enable logging
xdebug.remote_log=/tmp/xdebug.log
When I run php -m -v, I can see under Zend Modules that Xdebug is enabled/installed. My php version is PHP 7.1.32.
192.168.1.144 is the IP of my host machine. I also checked that PhpStorm is configured to listen on port 9000
When I created new configuration, I set IDE key(session id) as XDEBUG_ECLIPSE, also, when I defined server under configuration, host is correct (dummy.test), port is set to 80, and Debugger is set to Xdebug.
I also ran command tail -f /tmp/xdebug.log, and when I refreshed the page, there wasn't any new entry in the log file.
Any idea what am I missing? I set up breakpoint to one index function of xy controller and is not hit, I also enabled break at first line in PHP script.
so, with help of the topic owner it was found that for Mac host.docker.internal is set doc
as a hack-solution host ip was added to /etc/hosts inside docker container:
host-ip host.docker.internal
probably there should be a better solution :)

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

Categories