phpxdebugxdebug-profiler

How to use Xdebug on the terminal?


I am trying to find a way to debug PHP other than var_dump() and I noticed Xdebug. I cannot find on the internet if Xdebug has a command-line version (I dont want to use a GUI version, bear with me(sshing another linux system)). If there is, how can I use it? If no, is there any other PHP debugging tools that can be run as command-line?


Solution

  • xdebug

    1. Profiler:

    With xdebug, you might run the profiler from CLI with this command:

    php -d xdebug.profiler_enable=1 script.php
    

    In order, to run this on the console, the box you are ssh'ing into must have PHP and Xdebug installed and configured.

    1. Remote Xdebug:

    Another option would be to use xdebug.remote_host with SSH tunneling/forwarding.

    This allows to work with Netbeans or PHPStorm on the remote machine.

    1. Xdebug's DebugClient

    You might also use the simple DebugClient xdebug ships for CLI usage. Every other debugging client, which supports the dbg-protocol, should work, too. http://xdebug.org/docs/install#debugclient

    phpdbg

    If you run PHP 5.6, then you might use phpdbg, which is the integrated debugger and perfect for CLI usage.