开发者

How to know the xdebug version i have installed?

how to know the xdebug version i have installed?

Reg开发者_Python百科ards

Javi


php -v command output includes information about installed XDebug version:

$ php -v
PHP 5.6.13-1+deb.sury.org~trusty+3 (cli) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans

or

$ php -v | grep -i "xdebug"


You should be able to do it with a simple test script:

<?php
  phpinfo();
?>

And get output like this:

How to know the xdebug version i have installed?


On Debian-based distros such as Ubuntu:

aptitude show php5-xdebug | grep Version

On Redhat-based distros such as CentOS:

yum info php-pecl-xdebug | grep Version


I like using

php -r "var_dump(phpversion('xdebug'));"

from command line


From within PHP, use phpversion:

$version = phpversion('xdebug'); // "2.5.5"

Xdebug uses PHP-standardized version string format, so you can use version_compare on it:

if (version_compare('2.6.0.dev', $version, '<=')) {
    echo 'You are running at least the development version 2.6.0 of Xdebug';
}


[F.Y.I.] To detect whether xdebug is v3 or not by mashing up the @daniel and @bishop's answer.

php -r "exit(version_compare('3.0',phpversion('xdebug'),'>=')?1:0);"; echo $?

Useful for shell scripts in Dockerfiles and/or CIs.

#!/bin/sh

# bash compatible
if php -r "exit(version_compare('3.0',phpversion('xdebug'),'>=')?1:0);"; then
    echo 'if xdebug3 then rewrite php.ini, downgrade, and etc.'
fi

I needed this since I got the below error while running PHPUnit.

Fatal error: Uncaught RuntimeException: Error #2: Use of undefined constant XDEBUG_CC_UNUSED - assumed 'XDEBUG_CC_UNUSED' (this will throw an Error in a future version of PHP) on line 56 in file /workspaces/Sample/vendor/phpunit/php-code-coverage/src/Driver/Xdebug.php in /workspaces/Sample/tests/TestCase.php on line 9
  • Ref:
    • Xdebug 3.0.0 is out! @ xdebug.org
    • Upgrading from Xdebug 2 to 3 @ xdebug.org
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜