Koozali.org: home of the SME Server

Xdebug installation guide/contrib

Offline beast

  • *
  • 238
  • +0/-0
Xdebug installation guide/contrib
« on: April 06, 2019, 03:44:48 PM »
What is the best way to install xdebug for debugging php code?

Directly from source (where to place it) or PECL etc.

And how to edit php.ini etc.

This does not work out of the box: yum install php-pecl-xdebug.x86_64

Like to make a guide but need some help about the best and most simple way forward.

/Benny

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Xdebug installation guide/contrib
« Reply #1 on: April 06, 2019, 10:58:55 PM »
I'm not at a computer right now so can't exactly remember but I have remote debugging with xdebug. Couple of tricks required.

Give me a day or so and I'll sort out some notes.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,747
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Xdebug installation guide/contrib
« Reply #2 on: April 09, 2019, 04:51:49 AM »
Install smeserve-extrarepo for epel and remi-safe


Then

Yum install php*-pecl-xdebug —enablerepo=epel


This is with in mind the fact that you might have installed php-scl and might use a different version of php.
This way it will be installed for all of the available versions

For scl versions it should be working after a simple signal-event php-update.
For base version you might need a custom template fragment for /etc/php.ini in order to activate the module

Probably just reusing the content of /etc/php.d/xdebug.ini in this template would do. Of course expand template and restart httpd-e-smith
« Last Edit: April 09, 2019, 04:54:27 AM by Jean-Philippe Pialasse »

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #3 on: April 09, 2019, 06:52:21 AM »
Great - will test it out

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #4 on: April 11, 2019, 08:49:12 AM »
This might be a stupid question but is it not always needed to set xdebug.remote_enable to true or is it possible to debug in another way with debugclient or similar?

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #5 on: April 11, 2019, 08:57:34 AM »
BTW: It is not possible for me to edit

/etc/e-smith/templates/opt/remi/phpxx/root/etc/php.ini

As it is not a normal file - it seam to redirect to a template folder???

How do I edit this file as specified in: https://wiki.contribs.org/PHP_Software_Collections#Enable

Offline janet

  • ****
  • 4,812
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #6 on: April 11, 2019, 09:09:11 AM »
beast

See this tutorial for instructions, I STRONGLY ADVISE you read the whole article & then follow the example in php.ini section. Modify it to suit your particulars.
https://wiki.contribs.org/Template_Tutorial
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Xdebug installation guide/contrib
« Reply #7 on: April 11, 2019, 10:03:44 AM »
BTW: It is not possible for me to edit

/etc/e-smith/templates/opt/remi/phpxx/root/etc/php.ini

As it is not a normal file - it seam to redirect to a template folder???

As Janet said, read the documentation on templates. That directory contains the template fragments that generate the file.

So normally the template fragments would expand the file /opt/remi/phpxx/root/etc/php.ini

However, just to complicate things even further, you will notice that the file /opt/remi/phpxx/root/etc/php.ini doesn't actually exist.

When you modify the SCL PHP template fragments and re expand the file via signal-even php-update it actually expands to:

Code: [Select]
/etc/opt/remi/php71/php.ini
(I have no idea why)

I suggest you copy the dir

Code: [Select]
/etc/e-smith/templates/opt/remi/php71/root/etc/php.ini
over to

Code: [Select]
/etc/e-smith/templates-custom/opt/remi/php71/root/etc/php.ini
And then start looking at the fragments (files) in the custom directory.

You probably want to adjust this:

[root@esmith php.ini]# cat 80ModuleSettings03Debugger

Code: [Select]
[Debugger]
debugger.host                          = localhost
debugger.port                          = 7869
debugger.enabled                       = False

Now, if you want to get to be a really cool cat you can actually add yourself a bit of code and key to easily enable/disable this

Code: [Select]
[Debugger]
debugger.host                          = localhost
debugger.port                          = 7869
debugger.enabled                       = {
    my $debug = $php71{Debugger} || "False";
    $OUT .= "$debug";
}

signal-event php-update and check the php.ini file and it should default to False.

Code: [Select]
config setprop php71 Debugger True
Then signal-event php-update again.

See what happens.
« Last Edit: April 11, 2019, 10:26:06 AM by ReetP »
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Xdebug installation guide/contrib
« Reply #8 on: April 11, 2019, 10:34:47 AM »
I have modded the Wiki a bit. It may need some more tweaking.

Please ask - it took me a while to get remote debugging running but got there in the end, both for single use, and for multi users with a debug proxy.

Komodo IDE have a debug proxy which allows multiple users to connect to the same server. It's pretty neat.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline Jean-Philippe Pialasse

  • *
  • 2,747
  • +11/-0
  • aka Unnilennium
    • http://smeserver.pialasse.com
Re: Xdebug installation guide/contrib
« Reply #9 on: April 11, 2019, 07:50:59 PM »
Templates.metada folder and subfolder are used in order to point the template to a different path.

It could be for dome different reason. Smb.conf file for example has change folder. Templates were kept at the original location.

Php scl is because first version were in /opt. Recent are in /etc/opt /var/opt /usr/opt ....

So to help maintain the contrib original path has been kept And metada put in place.
By the way you could user expand-template commande with both paths. Template and original file. 

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #10 on: April 12, 2019, 07:36:35 AM »
I know about the template system. I was just confused about the text description at https://wiki.contribs.org/PHP_Software_Collections#Enable

That has now been changed ;-)

I will try to follow the new directions
« Last Edit: April 12, 2019, 07:41:46 AM by beast »

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Xdebug installation guide/contrib
« Reply #11 on: April 12, 2019, 07:59:08 AM »
Yeah I took a look and realisex it needed modding a bit.

Let us know if you get stuck.
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #12 on: April 13, 2019, 08:12:43 AM »
Not working just yet.

Implemented the changes and have the phpinfo below but seam unable to debug?

Have installed the following 2 tools to debug in Chrome:

https://chrome.google.com/webstore/detail/xdebug-helper/eadndfjplgieldjbigjakmdgkmoaaaoc
https://chrome.google.com/webstore/detail/xdebug/nhodjblplijafdpjjfhhanfmchplpfgl/related?hl=en-GB&gl=GB

But it does not seam to make a connection with the server....

Any suggestions?

PS: Also get this in the log all the time now (reason?): Xdebug could not open the remote debug file '/var/log/xdebug.log'

NB: Phpinfo below

Code: [Select]
xdebug
xdebug support enabled
Version 2.7.1
IDE Key no value
Support Xdebug on Patreon
BECOME A PATRON
Supported protocols
DBGp - Common DeBuGger Protocol
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.filename_format no value no value
xdebug.force_display_errors Off Off
xdebug.force_error_reporting 0 0
xdebug.gc_stats_enable Off Off
xdebug.gc_stats_output_dir /tmp /tmp
xdebug.gc_stats_output_name gcstats.%p gcstats.%p
xdebug.halt_level 0 0
xdebug.idekey no value no value
xdebug.max_nesting_level 256 256
xdebug.max_stack_frames -1 -1
xdebug.overload_var_dump 2 2
xdebug.profiler_aggregate Off Off
xdebug.profiler_append Off Off
xdebug.profiler_enable Off Off
xdebug.profiler_enable_trigger Off Off
xdebug.profiler_enable_trigger_value no value no value
xdebug.profiler_output_dir /tmp /tmp
xdebug.profiler_output_name cachegrind.out.%p cachegrind.out.%p
xdebug.remote_addr_header no value no value
xdebug.remote_autostart Off Off
xdebug.remote_connect_back Off Off
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.log /var/log/xdebug.log
xdebug.remote_mode req req
xdebug.remote_port 9000 9000
xdebug.remote_timeout 200 200
xdebug.scream Off Off
xdebug.show_error_trace 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_enable_trigger_value no value no value
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
« Last Edit: April 13, 2019, 09:45:50 AM by beast »

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Xdebug installation guide/contrib
« Reply #13 on: April 13, 2019, 03:43:19 PM »
You really must go and read more on running remote debuggers so you can configure yours specifically rather than guessing & hoping.

Start here....

https://xdebug.org/docs/remote

The settings illustrated on the wiki are just that. Illustrations.

Unless you use a debug proxy the remote host is the IP of your desktop. That's your immediate problem.

Personally I always used Firefox as the trigger eg:

http://some.local.debug.server/code.php?XDEBUG_SESSION_START

Or

http://some.local.debug.server/code.php?data=somedata&XDEBUG_SESSION_START

And that would the kick start my debugging program. Used to use Eclipse but these days KomodoIDE (can't remember is the community version of Komodo does remote debugging.)

I prefer an proper IDE over some browser plugin.

YMMV
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

Offline beast

  • *
  • 238
  • +0/-0
Re: Xdebug installation guide/contrib
« Reply #14 on: April 13, 2019, 05:39:24 PM »
You really must go and read more on running remote debuggers so you can configure yours specifically rather than guessing & hoping.

Start here....

https://xdebug.org/docs/remote

The settings illustrated on the wiki are just that. Illustrations.

Unless you use a debug proxy the remote host is the IP of your desktop. That's your immediate problem.

I have read it to begin with and setting remote host does not improve on the situation.

NB: I will now try with xdebug.remote_connect_back = 1

This is the reason that I like to make a guide - it is not so simple.

I have now tried to set it up with Atom that I use as a editor - no luck so far ;-)
« Last Edit: April 13, 2019, 05:52:33 PM by beast »