Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Check if xdebug is working

Tags:

php

xdebug

Without installing a texteditor or an IDE, is it possible to test if xdebug is working, i.e. if it can debug php code?

The only part xdebug comes up in phpinfo() is the following:

Additional .ini files parsed /etc/php5/apache2/conf.d/mysql.ini, /etc/php5/apache2/conf.d/mysqli.ini, /etc/php5/apache2/conf.d/pdo.ini, /etc/php5/apache2/conf.d/pdo_mysql.ini, /etc/php5/apache2/conf.d/xdebug.ini

It is not mentioned in the phpinfo() anywhere else.

like image 830
oshirowanen Avatar asked Dec 26 '12 21:12

oshirowanen


People also ask

Why is xdebug not working?

Xdebug cannot connect to PhpStorm This means that Xdebug tries to connect to the host and can't make the connection. To fix the issue, set xdebug. remote_connect_back=0 ( xdebug. discover_client_host=false for Xdebug 3) and make sure that xdebug.

What port is xdebug listening on?

The port to which Xdebug tries to connect on the remote host. Port 9003 is the default for both Xdebug and the Command Line Debug Client. As many clients use this port number, it is best to leave this setting unchanged. This setting can additionally be configured through the XDEBUG_CONFIG environment variable.


1 Answers

Without actually doing some debugging, I guess you can't be certain that a debugger is working.

But you can be pretty sure -- I guess one should assume that if some aspects of xDebug are working then it would all be working.

Given that, you can confirm that xDebug is installed and in place by trying the following:

1) phpinfo() -- this will show you all the extensions that are loaded, including xDebug. If it is there, then it's a safe bet that it's working.

2) If that isn't good enough for you, you can try using the var_dump() function. xDebug modifies the output of var_dump() to include additional information. If this is in place, then xDebug is working.

3) xDebug modifies PHP's error output. If your program crashes with xDebug in place, you'll get more information about the failure than with the standard PHP crash output.

4) xDebug also adds a number of helper functions to PHP. You could try any of these to see if it's working. For example, the function xdebug_get_code_coverage() should exist and return an array. If it does, then xDebug is installed. If not, it isn't.

like image 156
Spudley Avatar answered Oct 01 '22 07:10

Spudley