Configure xdebug for php using vscode step by step [Solution] 2022

    By: Manu
    2 years ago
    Category: PHPViews: 45

    Ok to make xdebug working with php and visual studio we need to configure it. Follow these steps one by one


    Get php Info


    In your application add "phpinfo()" and get all php info. some thing like this

    <?php 
    phpinfo();
    
    exit;
    


    Which will output as


    now press "Ctr+a" to select all

    and visit this link

    there you need to past your php info

    this will provide you steps how to make xdebug work depending on your local setup

    In our case we are using xampp so we had to update php.ini file

    sudo nano /Applications/XAMPP/xamppfiles/etc/php.ini
    

    and we added

    zend_extension = /usr/local/lib/php/pecl/20210902/xdebug.so
    
    xdebug.start_with_request=yes
    
    xdebug.mode=debug
    
    xdebug.client_port=9005
    

    These settings might be different in your case. try different port number if 9005 does not work for you at last you can check xdebug configuration using

    <?php 
    xdebug_info();
    


    and in vscode