0

I have followed this guide:

Download xdebug-3.0.2.tgz
Install the pre-requisites for compiling PHP extensions.
On your Ubuntu system, install them with: apt-get install php-dev autoconf automake
Unpack the downloaded file with tar -xvzf xdebug-3.0.2.tgz
Run: cd xdebug-3.0.2

Run: phpize (See the FAQ if you don't have phpize).

As part of its output it should show:

Configuring for:
...
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

If it does not, you are using the wrong phpize. Please follow this FAQ entry and skip the next step.
Run: ./configure
Run: make
Run: cp modules/xdebug.so /usr/lib/php/20190902
Update /etc/php/7.4/cli/php.ini and change the line
zend_extension = /usr/lib/php/20190902/xdebug.so
Make sure that zend_extension = /usr/lib/php/20190902/xdebug.so is below the line for OPcache.
Please also update php.ini files in adjacent directories, as your system seems to be configured with a separate php.ini file for the web server and command line.

from https://xdebug.org/wizard where I put my phpinfo() server info about my system. So after completion, my /etc/php/7.4/cli/php.ini has these lines:

[opcache]
1768 zend_extension = /usr/lib/php/20190902/xdebug.so
1769 remote_enable=1
1770 remote_autostart=1
1771 report_zend_debug=1
...

But still if I try to generate this launch.json (default) config in VSCode:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000
        },
        {
            "name": "Launch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9000
        }
    ]
}

The Launch current open script (VSCode debugger) ignores break points. I have no idea what should I do know when the Xdebuger is installed config .json file is generated in VSCode, in order to not ignore the breakpoints. Any ideas?

output from xdebug wizard (the page with the guideline):

Installation Wizard
Summary

    Xdebug installed: 3.0.2
    Server API: Apache 2.0 Handler
    Windows: no
    Zend Server: no
    PHP Version: 7.4.9
    Zend API nr: 320190902
    PHP API nr: 20190902
    Debug Build: no
    Thread Safe Build: no
    OPcache Loaded: yes
    Configuration File Path: /etc/php/7.4/apache2
    Configuration File: /etc/php/7.4/apache2/php.ini
    Extensions directory: /usr/lib/php/20190902

You're already running the latest Xdebug version
...

yet, the after pasting the settings above to both /etc/php/7.4/cli/php.ini and to /etc/php/7.4/apache2/php.ini, the breakpoints are not working.

EDIT:

phpinfo() (xdebug section):

Feature Enabled/Disabled    Docs
Development Aids    ✔ enabled   
Coverage    ✘ disabled  
GC Stats    ✘ disabled  
Profiler    ✘ disabled  
Step Debugger   ✘ disabled  
Tracing ✘ disabled  
Directive   Local Value Master Value
xdebug.auto_trace   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.cli_color    0   0
xdebug.client_discovery_header  no value    no value
xdebug.client_host  localhost   localhost
xdebug.client_port  9003    9003
xdebug.cloud_id no value    no value
xdebug.collect_assignments  Off Off
xdebug.collect_includes (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.collect_params   (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.collect_return   Off Off
xdebug.collect_vars (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.connect_timeout_ms   200 200
xdebug.coverage_enable  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.default_enable   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.discover_client_host Off Off
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.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  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.gc_stats_output_dir  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.gc_stats_output_name gcstats.%p  gcstats.%p
xdebug.halt_level   0   0
xdebug.idekey   no value    no value
xdebug.log  no value    no value
xdebug.log_level    7   7
xdebug.max_nesting_level    256 256
xdebug.max_stack_frames -1  -1
xdebug.mode develop develop
xdebug.output_dir   /tmp    /tmp
xdebug.overload_var_dump    (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.profiler_append  Off Off
xdebug.profiler_enable  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_enable_trigger_value    (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_output_dir  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
xdebug.remote_autostart (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_connect_back  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_enable    (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_host  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_log   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_log_level (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_mode  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_port  (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.remote_timeout   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
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   (setting removed in Xdebug 3)   (setting removed in Xdebug 3)
xdebug.start_upon_error default default
xdebug.start_with_request   default default
xdebug.trace_enable_trigger (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_enable_trigger_value   (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_format 0   0
xdebug.trace_options    0   0
xdebug.trace_output_dir (setting renamed in Xdebug 3)   (setting renamed in Xdebug 3)
xdebug.trace_output_name    trace.%c    trace.%c
xdebug.trigger_value    no value    no value
xdebug.var_display_max_children 128 128
xdebug.var_display_max_data 512 512
xdebug.var_display_max_depth    3   3
milanHrabos
  • 2,010
  • 3
  • 11
  • 45
  • Show you Xdebug config / whole `xdebug_info();` or Xdebug section of the `phpinfo()` output (captured in the same way as you are trying to debug: a CLI or a web page) – LazyOne Feb 12 '21 at 22:33
  • `xdebug_info()` -> `Call to undefined function xdebug_info()`. `phpinfo()` has no output about xdebug. It is apparent the system does not even know about xdebug, even with done all the steps in the guideline – milanHrabos Feb 12 '21 at 23:30
  • 1
    That means that you have edited the wrong php.ini file then. `/etc/php/7.4/cli/php.ini` is for CLI environment. You need to do the same xdebug config for your webserver (Apache/whatever) that most likely will be using separate php.ini (do not forget to restart it after making changes) . Check the top most table for that info (what config files are used) from `phpinfo()` output. – LazyOne Feb 13 '21 at 00:28
  • That's if you are trying to debug a web page and did all that what I have asked in initial comment via web page of course. – LazyOne Feb 13 '21 at 00:31
  • @LazyOne still the `xdebug_info()` is undefined after inserting the same settings from `/etc/php/7.4/cli/php.ini` to `/etc/php/7.4/apache2/php.ini` after line with `[opcache]` (as is said in the guide). What's wrong? – milanHrabos Feb 13 '21 at 12:04
  • @LazyOne see edits from above what the wizard generated – milanHrabos Feb 13 '21 at 12:11
  • Restart Apache or whole PC just in case. The `phpinfo()` output via browser should have a mention of Xdebug at the end of the very first table (where it shows OPcache version, PHP version etc). If it shows it there, then post whole Xdebug section (as a screenshot) -- will be down closer to the end (as modules are listen in A-Z order). P.S. This is how `xdebug_info()` output looks like -- similar to what `phpinfo()` will show, just with some other bits. https://xdebug.org/docs/all_functions#xdebug_info – LazyOne Feb 13 '21 at 12:27
  • @LazyOne see edits – milanHrabos Feb 13 '21 at 13:25
  • 1
    Now you need to configure Xdebug (`xdebug.mode`, `client_port`, `client_host`, possibly `start_with_request` as well.) Something like https://stackoverflow.com/a/65141934/783119 (use `9003` as a port number as 9000 can be used by php-fpm on Linux/Mac). Now find a guide specific to VSCode that uses Xdebug v3 config params (as v2 params do almost nothing in v3). – LazyOne Feb 13 '21 at 14:00
  • Couple of links: 1) https://xdebug.org/docs/all_settings 2) https://xdebug.org/docs/upgrade_guide 3) https://learnxdebug.com/ 4) https://stackoverflow.com/a/65360138/783119 – LazyOne Feb 13 '21 at 14:01
  • @LazyOne Thank you very much!! I was struggling with this for 2 days! I was editing the wrong php.ini exactly as you said... – Borjovsky Mar 27 '23 at 16:36

1 Answers1

0

The critical line for me was:

xdebug.start_with_request = yes

xdebug.start_with_request documentation
Useful related answer from StackOverflow thread

For the php7.4-xdebug package shown under https://xdebug.org/docs/install#linux, my full conf is /etc/php/7.4/mods-available/xdebug.ini:

zend_extension=/usr/lib/php/20190902/xdebug.so
xdebug.remote_autostart = 1
xdebug.remote_enable = 1
xdebug.mode = debug
xdebug.start_with_request = yes
Evan Lesmez
  • 59
  • 1
  • 6