Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 592
zkytony Avatar asked Jan 21 '26 04:01

zkytony


1 Answers

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.

  • Forwarding is described here: http://derickrethans.nl/debugging-with-xdebug-and-firewalls.html
  • Remote Xdebugging here: http://xdebug.org/docs/remote

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.

like image 197
Jens A. Koch Avatar answered Jan 22 '26 16:01

Jens A. Koch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!