Search code examples
phpvisual-studio-codemagento2centos7xdebug

VSCode Xdebug PHP for Magento 2 - How to set breakpoints?


Is anyone using VSCode for developing in Magento? I have been using it for years for other languages, thus I found convenient to adopt it for Magento too.

However, I am not able to make it running. I followed all the steps recommended, but it did not worked:

yum install php-devel
yum install php-pear
yum install gcc gcc-c++ autoconf automake
pecl install xdebug-3.1.5

Add it to /etc/php.ini:

zend_extension="/usr/lib64/php/modules/xdebug.so"
xdebug.remote_enable = 1
chmod +x /usr/lib64/php/modules/xdebug.so
service httpd restart

I've installed Xdebug extension and launched the .json file for attaching the session:

"configurations": [
    {
        "name": "Listen for Xdebug",
        "type": "php",
        "request": "launch",
        "port": 9003
    } 

When I open Magento, the breakpoint is never met and stopped. Why?


Solution

  • I solved the issue by adding the following setting to the xdebug.ini file.

    xdebug.mode=debug
    xdebug.start_with_request=yes