Steve
Steve

Reputation: 2818

PHP Debugger will not stop at breakpoints: Eclipse & Xdebug


Client Side Tools: ( No Apache, No PHP )


Eclipse for PHP Developers

Version: Oxygen.2 Release (4.7.2)

Build id: 20171218-0600

Redhat Enterprise Linux 6.9

java version "1.8.0_101"

Java(TM) SE Runtime Environment (build 1.8.0_101-b13)

Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)


Remote Server Where The PHP web app is:


PHP 5.6.5

Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies

with Xdebug v2.2.7, Copyright (c) 2002-2015, by Derick Rethans


I've found previous posts on this topic. I didn't understand all of the things to try. I tried what I could understand, but did not have any luck. Mostly just using xdebug_break(); ( again, no luck )


I am using Eclipse and Xdebug to debug a remote PHP web site. My problem is I can not get the debugger to stop on the breakpoints I set.

I am doing remote PHP development with Eclipse and a "Synchronized PHP Project. Nothing except Eclipse is running on my computer.

I am using the Xdebug debugger on the remote server through Eclipse.

When I use the debugger it will go to the index.php. I can step through for a while and see the value of variables.

The problem is that Xdebug will not stop at any of the breakpoints I set.

I am including my Xdebug settings

Any clues as to how to find and fix the problem would be welcome

Xdebug Settings:

xdebug support,enabled
Version,2.2.7

DBGp - Common DeBuGger Protocol,$Revision: 1.145 $

Directive,Local Value,Master Value

xdebug.auto_trace,Off,Off
xdebug.cli_color,0,0
xdebug.collect_assignments,Off,Off

xdebug.collect_includes,On,On

xdebug.collect_params,0,0
xdebug.collect_return,Off,Off
xdebug.collect_vars,Off,Off

xdebug.coverage_enable,On,On
xdebug.default_enable,On,On

xdebug.dump.COOKIE,no value,no value
xdebug.dump.ENV,no value,no value
xdebug.dump.FILES,no value,no value
xdebug.dump.GET,no value,no value
xdebug.dump.POST,no value,no value
xdebug.dump.REQUEST,no value,no value
xdebug.dump.SERVER,no value,no value
xdebug.dump.SESSION,no value,no value

xdebug.dump_globals,On,On
xdebug.dump_once,On,On

xdebug.dump_undefined,Off,Off

xdebug.extended_info,On,On

xdebug.file_link_format,no value,no value

xdebug.max_nesting_level,100,100
xdebug.overload_var_dump,On,On

xdebug.profiler_aggregate,Off,Off
xdebug.profiler_append,Off,Off
xdebug.profiler_enable,Off,Off

xdebug.profiler_enable_trigger,On,On
xdebug.profiler_output_dir,/tmp,/tmp
xdebug.profiler_output_name,cachegrind.out.%t.%s,cachegrind.out.%t.%s

xdebug.remote_autostart,Off,Off

xdebug.remote_connect_back,On,On
xdebug.remote_cookie_expire_time,3600,3600
xdebug.remote_enable,On,On
xdebug.remote_handler,dbgp,dbgp
xdebug.remote_host,127.0.0.1,127.0.0.1
xdebug.remote_log,/var/log/xdebug/xdebug.log,/var/log/xdebug/xdebug.log
xdebug.remote_mode,req,req
xdebug.remote_port,9000,9000

xdebug.scream,Off,Off
xdebug.show_exception_trace,Off,Off
xdebug.show_local_vars,Off,Off
xdebug.show_mem_delta,Off,Off
xdebug.trace_enable_trigger,Off,Off

xdebug.trace_format,0,0
xdebug.trace_options,0,0
xdebug.trace_output_dir,/tmp,/tmp
xdebug.trace_output_name,trace.%c,trace.%c
xdebug.var_display_max_children,128,128
xdebug.var_display_max_data,512,512
xdebug.var_display_max_depth,3,3

Edit

I created an album of screen shots.

First one is an error message from Eclipse that happens when I leave it on all night.

The rest of the screen shots are pieces, in order ( top->down ) of my phpinfo output.

https://imgur.com/a/9DKev

There is no Zend section in my phpinfo() output, though there are these vars

report_zend_debug = on
zend.detect_unicode On
zend.enable_gc  On
zend.multibyte  Off 
zend.script_encoding = no value

Upvotes: 11

Views: 6994

Answers (4)

Tarun Lalwani
Tarun Lalwani

Reputation: 146490

If you follow below steps I think it should work

Latest XDebug version

Your XDebug version is from 2015 as per this https://xdebug.org/. So you should upgrade to the latest version

Setting up XDebug configuration

Setup a 99-xdebug.ini in your /usr/local/etc/php/conf.d/ or /etc/php/conf.d or /etc/php/5.6/cli/conf.d depending on which exists on your system

xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_handler=dbgp
xdebug.remote_port=9000
xdebug.remote_autostart=1
xdebug.remote_log=/tmp/xdebug.log

Create a SSH Debug Tunnel

The machine from where you want to debug, you need to start a SSH tunnel using

ssh -R 127.0.0.1:9000:127.0.0.1:9000 -p 22 <user>@<phpserver>

Configure Remote Path mapping in Eclipse

Configure eclipse for the debugging on port 9000 and remote paths and now it should work

Upvotes: 4

Jannes Botis
Jannes Botis

Reputation: 11242

From your description, it seems that:

  • the debug connection to your remote server is working
  • breaking points work on the index.php, but not anywhere else

My assumption is that the file mapping between local and server code is not working, more precisely eclipse cannot map your files to the server ones.

To solve this, you have to set the path mapping setting inside your eclipse project `s run/debug settings.

Go to:

  1. Project -> Properties from the menu
  2. Select Run/Debug Settings
  3. Edit your launch configuration settings
  4. On the tab Server, section PHP server, select configure
  5. "PHP Server" window is opened, select path mapping tab
  6. Set Path on server to your project `s path on server and set Local path to well this is self explanatory.

enter image description here

Upvotes: 8

LeonidMew
LeonidMew

Reputation: 502

Try to disable things like: opcache, zend optimizer, and so on, all extensions what work with interpretation php code. If you luck and it start working, make xdebug.so loads last, after all another modules, so you can re enable them again. Place xdebug.so in folder where all other php .so resides, and load it in last line of php ini, with full path to xdebug.so

If you just place it in last line php.ini, then some incompatible module can load up after, with config from /etc/php/5.6/apache2/conf.d/*. So just move configs somewhere for a while.

At the link, in bottom of post, I do disable(but do not remove by apt) opchache module totally, and place its in php.ini, 1 line before debugger.

Check order how extensions loaded in phpinfo() output, to the left of zend logo, as I remember. Debugger must be last line in that block of output. Post you phpinfo(); output.

Another way, what I walk my own: (and I recommend it)

If you have root access to remote server, try Zend Debugger. Its bundled with Zend Studio(not free), but there are separate downloads of debugger for some php versions, 5.6 is the latest version it available for. They don`t publish it for php7, anyway I don`t known if it possible to copy it from trial Zend studio. If it removed, unable to download, I can send it to you.

Zend debugger are more native for php now, And Zend team involved in Eclipse PDT development(but they realized most tasteful features in paid version)

I have similar environment to yours, also have problems with XDebug, then decided to remove it and try Zend debugger. There are my question and answer on askubuntu, about installing it and fix problems: https://askubuntu.com/questions/1002252/installing-configuring-zend-debugger-for-eclipse-pdt

In few words solution was:

Comment out it in config: (cli version seems to be symlink as also disabled)

lenya@JabbaDesktop:~$ sudo nano /etc/php/5.6/apache2/conf.d/10-opcache.ini

; configuration for php opcache module
; priority=10
; zend_extension=opcache.so

At bottom of /etc/php/5.6/apache2/php.ini:

[Zend]
zend_extension="/usr/lib/php/20131226/opcache.so"
zend_extension="/usr/lib/php/20131226/ZendDebugger.so"
zend_debugger.allow_hosts=127.0.0.0/8,192.168.0.0/16
zend_debugger.expose_remotely=1
zend_debugger.connector_port=10137

First two lines(.so) should be exactly in this order. Installing debugger "how to" easy to find in google. No one mention above problem.

Update:

When I use the debugger it will go to the index.php. I can step through for a while and see the value of variables.

This means you already have connection to server, problem is not there

Upvotes: 0

zulus
zulus

Reputation: 2505

I am doing remote PHP development with Eclipse and a "Synchronized PHP Project. Nothing except Eclipse is running on my computer.

This is your problem. You have to allow xDebug connection. xDebug (PHP Web Server) trying to connect but probably have no idea where you are ;)

There two options:

  1. If you are not behind NAT or in same network as your test server, you have to open port 9000 on your PC. If you are behind NAT you need also forward port 9000 (this is default, can be changed). Next set correct "xdebug.remote_host=your_public_ip" or xdebug.remote_connect_back = on. Would be also good to enable accepting remote sessions (JIT) from any host (Preferences -> PHP -> Debug -> Debuggers -> xDebug), after this you will be able to easy run debugger via browser extension like xDebug helper.

  2. Configure debugger launch configuration (small arrow after "debug" icon"), to debug through SSH Tunnel. In this case xdebug.remote_host=127.0.0.1 will be correct. Note: ssh server host have to be same as server domain and SSH server have to be available on port 22

Upvotes: 0

Related Questions