Search code examples
phpatom-editorxdebug

How to enable php-debug in Atom?


I have installed php-debug in Atom + its IDE dependencies. When I set a breakpoint the debug view opens saying The debugger is not attached, but when I am trying to do so it seems as if Atom doesn't recognize I have php-debug package installed and asks me to install a debugger.

I read on some places there is a toggle debugging setting on the package, but I can't see that option.

I'm using Atom 1.27.0 and PHP 7.2.4:

PHP 7.2.4 (cli) (built: Apr 12 2018 02:49:03) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Xdebug v2.6.0, Copyright (c) 2002-2018, by Derick Rethans
    with Zend OPcache v7.2.4, Copyright (c) 1999-2018, by Zend Technologies

I could provide Xdebug configuration but seems like the problem is on Atom itself? Did anyone have this problem?


Solution

  • very simple

    1. Download xdebug from https://xdebug.org/download.php, TS version for Apache
    2. Copy it to php/ext directory
    3. Copy below text in php.ini below all other extensions

    zend_extension="D:/wamp/php/ext/php_xdebug-2.6.1-7.2-vc15-x86_64.dll"
    [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

    Restart Apache and Find "xdebug" string in <?php phpinfo()?>

    • Install atom-debug_ui, php_debug
    • Package > PHP Debug > Toggle
    • Apply break-points and Run a PHP file from browser and that's it.

    If it ask for paths remote http://localhost/DIRECTORY_PATH_TO_PHP_FILE and local is directory path to PHP file.