We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Unable to debug Phalcon app in Visual Studio Code (VSCode) with XDebug

Hi,

I am using Wamp on Windows 10 64bit. I am unable to get my Phalcon application debugged using Visual Studio Code (VSCode) with XDebug. XDebug based debugging works fine on my normal core PHP application in VSCode but when I start debugging a Phalcon based application it stops at the first breakpoint and doesn't proceed, whatever I try - Continue (F5), Step Over (F10) etc. None of the keys or options work.

Has anybody got it to work. Here are my configuration files:

XDebug settings in php.ini

xdebug.remote_enable = 1
xdebug.remote_autostart = 1
xdebug.remote_connect_back=1

xdebug.profiler_enable = On
xdebug.profiler_enable_trigger = On
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="R:/Temp"
xdebug.show_local_vars=1
xdebug.remote_port = 9000
xdebug.remote_log=R:\Temp\xdebug.log

launch.json

{
    // 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 found some posts about how to get other framework like Laravel to work with VSCode but it hasn't helped me to get it to work with Phalcon. What I gather is that we need changes to launch.json to get it to work.

Thanks, Amal



771

Hey. I know that. It must be the class \Phalcon\Di. I have done the following.

class MyFactoryDefault extends \Phalcon\Di\FactoryDefault {}

If I use the class MyFactoryDefault, that's debugging too.

edited Jul '19

Hi @Dziuba

I have the exact same issue on ubuntu 18.04 with php7.3.7 and Xdebug v2.7.1

Your solution is a great workaround. I see the issue with both Phalcon\Di\FactoryDefault and with Phalcon\Config