by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    kboogert
    @kboogert
    @real-mielofon - Open debug window, expand breadpoints panel (or unhide the breakpoint panel), uncheck everything but Exceptions.
    waffeln
    @waffln

    @waffln - weird... the symptoms you are describing indicate that XDebug isn't able to get it's way to your workspace directory. I know it's very picky when it comes to case sensitivity, shortcuts, etc. even when it comes to the drive letter. If it were me, I'd create a pathMapping between the explicit text in your Apache configuration (I think it's httpd-vhosts.conf) and ${workspaceFolder} something like:

     "pathMappings": {
       "whatever Apache is configured to": "${workspaceFolder}/subdirectory-your-site-is-in-if-applicable"
    },

    Other than that, I'd turn on Xdebug logging as described in:
    https://github.com/felixfbecker/vscode-php-debug
    look for errors about not being able to open a file

    Unfortunately that didn't work...

    It still won't halt at breakpoints, and when using xdebug_breakpoint() the local variables are empty.
    TheLeank
    @TheLeank

    Hello everyone! I've been trying something this whole morning and finally I'm here to ask for help to someone that could enlighten me...

    I'm trying to debug an app to which I'm remotely connected via ssh (so no pathMappings should be defined, right? Because I have no files on my computer)
    I'm too dumb to set this up by myself or it's not possible at all?

    xdebug.ini

    [xdebug]
    zend_extension=/usr/lib/php/20151012/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_autostart=1
    xdebug.remote_connect_back=1
    xdebug.remote_log=/var/log/xdebug/xdebug.log

    The launch.json is left untouched (tried to "log": true but there's no output that I can see, nor in the server)

    Thank your for reading and helping me if you can!

    EDIT: Some more info. The debugger doesn't attach when I visit the app (is a website) in my browser, the page just loads and I can browser as always. It just goes by the breakpoints without stopping. I can't see the vars in the sidebar either. I tried the same with sublime-3 without luck some weeks ago, it just worked with local code and pathMapping set (almost like everybody else does, cause I was connected by ftp and had some files, not the whole project, in my local machine)

    waffeln
    @waffln
    @TheLeank You need pathMappings exactly then.
    For you, index.php could be located in \\192.168.0.22\www\mySite\, but for the server it's located at /var/www/mySite/ (for example)
    That's when you need to tell VSCode-Debug to take this difference into account.
    TheLeank
    @TheLeank
    Gonna try!
    TheLeank
    @TheLeank
    Well, it finally worked. It was the xdebug.remote_connect_back=1, just deleted it. Tried with the pathMappings as waffln suggested but still didn't work (yet your answer encouraged me to look further, so thank you, really). Xdebug wasn't able to connect to vscode, after all. I still need to check if all of it's functionalities work, but looks good for now. I'm really new at this, but I'll be glad to help here :)
    Jason T
    @jasonterando
    @waffln What's your launch.json look like?
    crazyJinx
    @crazyJinx
    @kboogert Thanks for your suggestion.I have Known what the problem is:when I debug php cli as the above configuration,The CLI launch local, can't connect to the remote(docker).still I don't know how to configure the launch.json.
    TheLeank
    @TheLeank
    @crazyJinx Does xdebug show when you execute php -m? If not, remember to copy the xdebug.ini to the php/cli/conf.d dir, then check again
    Jason T
    @jasonterando

    @waffln - in Windows, there was (maybe is) an issue with drive letter casing. Assuming you are opening VSCode in your c:\someplace directory, have you tried something like this? (I would test it myself, but it's been a while since I've wrestled this beast in Windows)

            "pathMappings": {
                "C:\\somepath": "${workspaceFolder}",
                "c:\\somepath": "${workspaceFolder}"
            },

    References:
    felixfbecker/vscode-php-debug#242
    microsoft/vscode#43959

    waffeln
    @waffln
    I did try "C:\somepath", but i'll try lowercase now
    Jason T
    @jasonterando
    @waffln - any luck? If not, I've got some time to kill tonight, I can try putting on XAMP on a Windows VM
    waffeln
    @waffln
    @jasonterando Didn't work unfortunately =/
    Jason T
    @jasonterando
    @waffln - being the masochist that I am, I spun up a Windows 10 VM and installed XAMPP, using PHP 7.2 version. I created a directory called "c:\somepath", updated my httpd.conf as you did (but I left the port at 80), and XDEBUG worked (i.e. stopping on breakpoints), with and without the pathMappings entry. So, sorry man, I'm stuck. I gotta say that XAMPP was kind of painful (to me) than going the Docker for Windows route.
    { // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000, "pathMappings": { "C:\\somepath": "${workspaceFolder}" } } ] }
    waffeln
    @waffln
    Yeah i'll probably just force "bisect" my way through with a new workspace and stuff until it works.
    Steven
    @StevenRose_twitter
    Is there any launch.json config to support phalcon debugging?
    Steven
    @StevenRose_twitter
    To be more precise, I downloaded the source of phalcon, but I'm not sure how to tell the plugin/vscode how to resolve the use statements to that source code
    Giannis Taranas
    @gtaranas
    hi @rogerzanelato i have the same problem is there any fix on that?
    Dan
    @collisiondetection
    If the app I debugging is on an Ubuntu VM and I running VSCODE from windows 10 what should my pathmappings be ?
    Dan
    @collisiondetection
    Ok I just needed to add "pathMappings": { "/var/www/": "${workspaceRoot}/",
    kboogert
    @kboogert
    I have apache/php server running in a docker container. I have mapped my local directory to the /var/www/html directory (apache root document folder). As you can see from my questions above, I am getting a connection. BUT..... I don't see any break points. Does someone understand how breakpoints I set in my vscode (running on mac) are supposed to be recognised by xdebug (in the docker container). Again please see my setting and results above.
    riccode
    @riccode

    Getting some really frustrating behavior with connecting xdebug/vscode/vagrant (running centOS). I have set up everything according to the documentation and various forums online. Xdebug is installed and up and running. I can check the logs and it says its connected.

    [2292] Log opened at 2020-04-23 16:27:30
    [2292] I: Connecting to configured address/port: 10.0.2.2:9000.
    [2292] I: Connected to client. :-)

    If I set a breakpoint in vscode it will never stop. The log will spit out some lines that include the line where the breakpoint is set and then show this:

    [2292] <- run -i 3 [2292] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="3" status="stopping" reason="ok"></response>
    [2292] <- stop -i 4 [2292] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="stop" transaction_id="4" status="stopped" reason="ok"></response>

    If I manually add an:

    xdebug_break();

    The debugger will stop but vscode will open an error window in the bottom right hand side:

    Unable to open 'myfile.php': Unable to read file '\var\www\html\pathtomyfile.php' (Error: Unable to resolve non-existing file '\var\www\html\pathmyfile.php')

    I can sort of step through the code but each time I step vscode opens the error window and the line I'm on is not highlighted. The path to my file is correct, but the slashes are the wrong way. If I pwd at the file it's looking for it should be '/var/www/html/pathtomyfile.php'.

    My path mapping is:

      "pathMappings": {
                "/home/vagrant/syn/mywebsite": "${workspaceFolder}",
              },

    Any help is greatly appreciated.

    Jason T
    @jasonterando

    @riccode - your path mapping has to be set up to map the directory as far as the webserver is concerned (i.e. /var/www/html) and your editing file system.

       "pathMappings": { "/var/www/html": "${workspaceFolder}" }

    should work, provided your files like pathtomyfile.php is in your base workspace folder. If your site files are in a directory like "mywebsite" then you would need:

       "pathMappings": {"/var/www/html": "${workspaceFolder}/mywebsite" }
    riccode
    @riccode
    Well, when you say it like that it's so obvious. It is indeed working. Thanks for pointing out my blunder Jason T, keep on making the world a better place.
    Jason T
    @jasonterando
    @riccode - cool, I did something useful this week :)
    tabruhn
    @tabruhn_twitter
    Cannot evaluate code without a connection
    How can I troubleshoot the connection?
    harmitsng
    @harmitsng

    I am facing an issue with PHP Debug extension is that when i start debugging it never stopes at break point. And the buttons in the toolbar step over, step into, step out are disabled.

    These are the php.ini configurations

    [XDebug]
    zend_extension = "/Applications/XAMPP/xamppfiles/lib/php/extension/no-debug-non-zts-20170718/xdebug.so"
    xdebug.remote_log = "/Applications/XAMPP/logs/xdebug_log"
    xdebug.idkey = "session_name"
    php myscript.php
    xdebug.remote_autostart = 1
    xdebug.remote_enable = 1
    xdebug.remote_port = 9000
    xdebug.remote_handler = "dbgp"
    xdebug.remote_host = "localhost"
    xdebug.idekey = VSCODE
    xdebug.trace_output_dir = "/Applications/XAMPP/xamppfiles/temp"
    xdebug.remote_cookie_expire_time = 36000

    This is somthing I am getting into xdebug log file:

    [37308] Log opened at 2020-05-10 21:10:57
    [37308] I: Connecting to configured address/port: localhost:9000.
    [37308] I: Connected to client. :-)
    [37308] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///Applications/XAMPP/xamppfiles/htdocs/php/multidimensional-array.php" language="PHP" xdebug:language_version="7.2.30" protocol_version="1.0" appid="37308" idekey="harmeetsingh"><engine version="3.0.0-dev"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url>![CDATA[https://xdebug.org]]</url><copyright><![CDATA[Copyright (c) 2002-2020 by Derick Rethans]]></copyright></init>

    [37308] <- breakpoint_list -i 1
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="1"></response>

    [37308] <- breakpoint_set -i 2 -t line -f file:///Applications/XAMPP/xamppfiles/htdocs/php/multidimensional-array.php -n 5
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="2" id="373080010"></response>

    [37308] <- breakpoint_list -i 3
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="3"><breakpoint type="line" filename="file:///Applications/XAMPP/xamppfiles/htdocs/php/multidimensional-array.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="373080010"></breakpoint></response>

    [37308] <- breakpoint_list -i 4
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_list" transaction_id="4"><breakpoint type="line" filename="file:///Applications/XAMPP/xamppfiles/htdocs/php/multidimensional-array.php" lineno="5" state="enabled" hit_count="0" hit_value="0" id="373080010"></breakpoint></response>

    [37308] <- breakpoint_set -i 5 -t exception -x Notice
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="5" id="373080011"></response>

    [37308] <- breakpoint_set -i 6 -t exception -x Warning
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="6" id="373080012"></response>

    [37308] <- breakpoint_set -i 7 -t exception -x Error
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="7" id="373080013"></response>

    [37308] <- breakpoint_set -i 8 -t exception -x Exception
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="8" id="373080014"></response>

    [37308] <- breakpoint_set -i 9 -t exception -x *
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="breakpoint_set" transaction_id="9" id="373080015"></response>

    [37308] <- run -i 10
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="run" transaction_id="10" status="stopping" reason="ok"></response>

    [37308] <- stop -i 11
    [37308] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="h

    ermGit
    @ermGit

    Good morning or whatever it is for you. I am trying to get vscode-php-debug to work.
    I am on a Mac
    my Xdebug configuration looks like this:
    [xdebug]
    zend_extension="xdebug.so"
    xdebug.remote_enable=1
    xdebug.remote_host=localhost
    xdebug.remote_handler=dbgp
    xdebug.remote_port=9000

    I have Xdebug setup to star as a service

    My Site is located in my user directory:
    ~/Sites/wp-site

    My WorkSpace is the same directory
    ~/Sites/wp-site

    I have "mysite.eric" mapped to bring up the site. That works when I type it in the Chrome.

    How do I get breakpoints to work in VsCode?
    Do I need pathMappings?

    ermGit
    @ermGit

    My launch.json looks like this:
    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "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
    }
    ]
    }

    I want to be able to start the debug session in VsCode and either have it open Chrome or when I open Chrome it will use the break points.

    kboogert
    @kboogert
    Has anyone been successful in stepping through php code in a docker container using PHP Debug in vscode?
    Jason T
    @jasonterando
    @kboogert - yes, this article was written for Windows, if you are on Linux, let me know, there's an additional step:
    https://medium.com/@jasonterando/debugging-with-visual-studio-code-xdebug-and-docker-on-windows-b63a10b0dec
    Ludwig Göbkes
    @lgoebkes

    Hello there,
    I'm trying to setup xdebug with docker and vscode (on Mac) but I'm stuck.
    I searched all over the whole internet but can't find a solution.

    Currently I can connect with xdebug and if i check "Everything" or "Exceptions" inside the vscode-php-debug window I actually stops on these. But no matter where i set a Breakpoint it just jumps over it without stopping. I get "no such breakpoint" and "command not available" messages in vscode.

    The log contains messages like:

      XDebugError: no such breakpoint
          at new Response (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:56:19)
          at Connection.<anonymous> (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:611:20)
          at Generator.next (<anonymous>)
          at fulfilled (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:4:58)
          at processTicksAndRejections (internal/process/task_queues.js:85:5) {
        code: 205,
        name: 'XDebugError'
      }
      XDebugError: command is not available
          at new Response (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:56:19)
          at Connection.<anonymous> (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:611:20)
          at Generator.next (<anonymous>)
          at fulfilled (/Users/myusername/.vscode/extensions/felixfbecker.php-debug-1.13.0/out/xdebugConnection.js:4:58)
          at processTicksAndRejections (internal/process/task_queues.js:85:5) {
        code: 5,
        name: 'XDebugError'
      }

    My launch.json looks like:

    {  
      "version": "0.2.0",
      "configurations": [
        {
          "name": "Listen for XDebug",
          "type": "php",
          "request": "launch",
          "port": 9000,
          "pathMappings": {
             "/srv/pim/": "${workspaceFolder}/"
          }
        }
      ]
    }

    The command php -i | grep xdebug shows the following output:

    /etc/php/7.2/cli/conf.d/20-xdebug.ini,
    xdebug
    xdebug support => enabled
    Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
    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.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 => VSCODE => VSCODE
    xdebug.max_nesting_level => 500 => 500
    xdebug.max_stack_frames => -1 => -1
    xdebug.overload_var_dump => 2 => 2
    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_host => host.docker.internal => host.docker.internal
    xdebug.remote_log => no value => no value
    xdebug.remote_log_level => 7 => 7
    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

    I tried many different things but I just can't seem to get it to work. Is there something you would suggest on doing/checking?

    waffeln
    @waffln
    Alright so i've had some issues with the plugin not showing me local variables and also not respecting breakpoints.
    I've mostly ignored PHP debug the past month or two, and tried it out again today. To my surprise, both breakpoints and showing local variables worked.
    But now i'm debugging a different line in the same project (and workspace and config) and it won't show the local variables anymore...
    I have a hint though: I'm seeing this in the log:
    -> variablesRequest
    {
      command: 'variables',
      arguments: { variablesReference: 1 },
      type: 'request',
      seq: 12
    }
    
    <- variablesResponse
    Response {
      seq: 0,
      type: 'response',
      request_seq: 12,
      command: 'variables',
      success: true,
      body: { variables: [] }
    }
    So i'm thinking now that it might be an issue with Xdebug and not PHP Debug. Any ideas?
    waffeln
    @waffln

    Regarding the missed breakpoints, i found something interesting from this page about PHP Xdebug troubleshooting for PHPStorm:
    https://www.jetbrains.com/help/phpstorm/troubleshooting-php-debugging.html :

    There are some rare cases when breakpoints can't be hit due to technical limitations, for example caused by the way how PHP generates bytecode. See here for more details.

    That link goes here: https://youtrack.jetbrains.com/issue/WI-20398#comment=27-599855

    The PHPStorm link also recommends to enable Xdebug remote logging and check the log, which i'll do now.
    waffeln
    @waffln
    Yeah, xdebug just doesn't send anything: https://gist.github.com/waffln/be78acd9e9e425a29b427ab02be1c928
    The response for transaction_id="24" (the middle block) should have sent the local variables if i'm not mistaken, just like the third block is sending the superglobals (which i've cut off in the log because of the length).
    waffeln
    @waffln
    I GOT IT
    I found another post online which pointed towards xdebug.collect_vars. This is incredibly badly documented here: https://xdebug.org/docs/all_settings
    I already had collect_params enabled, so i never thought about this setting.
    tl;dr adding xdebug.collect_vars = 1 in my php.ini fixed it. I didn't have to disable opcache. Sorry for the wall of text.
    Jean-Philippe Murray
    @jpmurray
    Is there a config that I can get an alert on errors when I'm saving a file ?