Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XDebug does not break on breakpoints from atom's php-debug package

My problem is one I found many other answers too but none worked for me. The code and "server" are both localhost. Edit: tried using port 9001 instead as suggested in some answers + tried if Visual Studio Code worked, but the strange thing is: it breaks on exceptions in VS Code but still not on breakpoints. The connection seems to work:

enter image description here

My setup

Software

  • Windows 10 Pro x64
  • MAMP (non pro) running port 81
  • atom
  • php-debug package
  • xdebug-2.4.1-7.0-vc14.dll extention
  • the code to be debugged is written inside the Laravel framework

Configs

PHP info xdebug part

(full)
     xdebug

      xdebug support    enabled
    Version 2.4.1
    IDE Key XDEBUG_ECLIPSE
    XDEBUG NOT LOADED AS ZEND EXTENSION
    Supported protocols Revision
    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.force_display_errors Off Off
    xdebug.force_error_reporting    0   0
    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  C:\Windows\Temp C:\Windows\Temp
    xdebug.profiler_output_name cachegrind.out.%p   cachegrind.out.%p
    xdebug.remote_addr_header   no value    no value
    xdebug.remote_autostart On  On
    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   no value    no value
    xdebug.remote_mode  req req
    xdebug.remote_port  9000    9000
    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 C:\Windows\Temp C:\Windows\Temp
    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

php.ini xdebug part

(full)
[xdebug]
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_connect_back=1    # Not safe for production servers
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_autostart=true
xdebug.idekey=xdebug.atom
like image 498
online Thomas Avatar asked Oct 21 '16 09:10

online Thomas


People also ask

Why is Xdebug not working?

Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.

How do I debug Xdebug?

Press F5 to start the debugger. Click the new XDebug Helper extension and click the Debug option. Finally, refresh the page in the browser to let VSCode react and start the debugging process.


2 Answers

I've uploaded your PHP info output here - https://xdebug.org/wizard.php. And among others I've got next message: "You seem to have Xdebug loaded as a normal PHP extension only. This will cause odd issues, please see https://xdebug.org/docs/faq#php-ext"

Q: Xdebug is only loaded as PHP extension and not as a Zend Extension.

In order for Xdebug to work properly, including breakpoints etc. it is required that it is loaded as a Zend extension, and not just as a normal PHP extension. Some installation tools (PEAR/PECL) sometimes advice you to use extension=xdebug.so to load Xdebug. This is not correct. In order to fix this issue, please look for a line extension=xdebug.so in any of the INI files that are listed under "Loaded Configuration File" and "Additional .ini files parsed" in the top block. Remove this line, and go back to the Tailored Installation Instructions.

So here is the instructions for your case:

  1. Download php_xdebug-2.4.1-7.0-vc14.dll
  2. Move the downloaded file to C:\MAMP\bin\php\php7.0.9\ext
  3. Edit C:\MAMP\conf\php7.0.9\php.ini and add the line zend_extension = C:\MAMP\bin\php\php7.0.9\ext\php_xdebug-2.4.1-7.0-vc14.dll
  4. Restart the webserver

Also you may take a look at special kind of "debug" functions, which came with xdebug extension - https://xdebug.org/docs/all_functions

For example you can use xdebug_break(). It allows you to specify breakpoints without using IDE.


And one note regarding Atom setup. On this page https://atom.io/packages/php-debug you may find explanation of the configuration process. I'd like to put your attention on config.cson file. Check out my config snippet below. Do you have something similar in your project?

"php-debug": 
{
    ServerPort: 9000
    PathMaps: [
        "remotepath;localpath"      
    ]
}
like image 146
Vladimir Posvistelik Avatar answered Oct 31 '22 23:10

Vladimir Posvistelik


Just a shot in the dark, but have you tried to set a breakpoint at the very entry point of your framework ?

I had a similar issue with another framework and your problem may just be that xdebug can't do the mapping with the local files, and setting a breakpoint on the very first executed line may solve that.

For example, PhpStorm has an debug option called "Break at the first line" which solved the issue for me.

like image 38
Alucara Avatar answered Oct 31 '22 22:10

Alucara