Install Xdebug; require PHP 7 while it installed - xdebug

When I type command php -v in Linux CentOS 7 the output is:
PHP 7.2.2 (cli) (built: Feb 19 2018 03:52:18) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
But when in try to install Xdebug I got this error:
configure: error: not supported. Need a PHP version >= 7.0.0 and < 7.3.0 (found 5.6.33)
What's the problem?
EDIT
I rebuild my PHP version and that solved it.

I rebuild my php version and solved

Related

Configure xdebug on portable drive

I am trying to set xdebug. I do use XAMPP portable, PHP v 7.4.11. I downloaded dlls php_xdebug-3.0.2-7.4-vc15-x86_64.dll and php_xdebug-3.0.2-7.4-vc15-nts-x86_64.dll and put them in \xampp\php\ext. Then I set php.ini file:
implicit_flush = On
zend_extension_ts = H:\xampp\php\ext\php_xdebug-3.0.2-7.4-vc15-x86_64.dll
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9000
xdebug.remote_handler="dbgp"
xdebug.profiler_enable = 0
xdebug.profiler_output_dir = \tmp
xdebug.dump_globals=On
xdebug.show_exception_trace=On
xdebug.collect_params=4
I restarted server, but I can not see any info about xdebug at http://localhost/dashboard/phpinfo.php or among modules in php shell. I have tried both downloaded dlls, various ports, relative/absolute path. Nothing works. There are a few tutorials online, but they might be out of date, or is there problem with portable setting? Any idea, please?
I changed dll`s path and settings:
zend_extension=php_xdebug-3.0.2-7.4-vc15-x86_64.dll
[XDebug]
xdebug.mode=debug
xdebug.client_host = localhost
xdebug.client_port = 9003
xdebug.remote_handler="dbgp"
xdebug.output_dir = H:\xampp\tmp
Now after php -v in php console I get:
PHP 7.4.11 (cli) (built: Sep 29 2020 13:18:06) ( ZTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v3.0.2, Copyright (c) 2002-2021, by Derick Rethans
So that is good. At http://localhost/dashboard/phpinfo.php:
According to https://wiki.php.net/internals/extensions, since php 5.5 there is no needed to fill whole path to dll, only it`s name

PHPUnit gives No Code Coverage Driver Is Available

I have a laravel project and I tried to run phpunit to give me a coverage report. I ran the command vendor/bin/phpunit --coverage-html storage/test-output-data/coverage-html and it gave the output:
PHPUnit 8.5.8 by Sebastian Bergmann and contributors.
Error: No code coverage driver is available
I tried to resolve this situation by doing a sudo pecl install pcov, but running the phpunit still gave the same error above.
I noticed that I have the file /usr/lib/php/20170718/pcov.so. So I added the line extension=/usr/lib/php/20170718/pcov.so to my /etc/php/7.4/cli/php.ini file. But when I type php -v, I get this error:
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/pcov.so' (tried: /usr/lib/php/20170718/pcov.so (/usr/lib/php/20170718/pcov.so: undefined symbol: _zval_ptr_dtor), /usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so (/usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.11 (cli) (built: Oct 10 2020 19:44:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.11, Copyright (c), by Zend Technologies
I also have a folder called /usr/lib/php/20190902 but it does not have a pcov.so file.
I also tried doing a sudo pecl install xdebug, but I run into similar errors as above where phpunit says there's no driver and typing php -v says some global variable is missing similar to the pcov issue.
What am I doing wrong?
I noticed that I have the file /usr/lib/php/20170718/pcov.so. So I added the line extension=/usr/lib/php/20170718/pcov.so to my /etc/php/7.4/cli/php.ini file.
This file is for PHP 7.2 (based on 20170718 part) while you are trying to use it in PHP 7.4.
You need to get the right version of Xdebug (or PCOV) for your PHP 7.4. (NOTE: for PHP 7.4 the API version (and the right folder in the path) will be 20190902.)
Try this solution from the following answer to switch / install extensions via PECL for specific PHP version (7.4 instead of your current 7.2): https://stackoverflow.com/a/54594604/783119
sudo pecl -d php_suffix=7.4 install <package-name>
This has nothing to do with PHPUnit. You have a problem with your PHP environment: "PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/20170718/pcov.so' (tried: /usr/lib/php/20170718/pcov.so (/usr/lib/php/20170718/pcov.so: undefined symbol: _zval_ptr_dtor), /usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so (/usr/lib/php/20190902//usr/lib/php/20170718/pcov.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0"
You just need to install xdebug, so the coverage knows how to run.
For example, for PHP 7.1, it's this package:
sudo apt install php7.1-xdebug
Just fixed it today for my scenario. In your case, just change the PHP version to:
sudo apt install php7.4-xdebug

Xdebug doesn't show up as a module

System:
OS Name Microsoft Windows 10 Pro
Version 10.0.19041 Build 19041
dll location and version:
C:\xampp\php\ext\php_xdebug-2.9.8-7.4-vc15-x86_64.dll
php.ini info:
C:\xampp\php\php.ini
[XDebug]
zend_extension = C:\xampp\php\ext\php_xdebug-2.9.8-7.4-vc15-x86_64.dll
phpinfo():
This program makes use of the Zend Scripting Language Engine: Zend
Engine v3.4.0, Copyright (c) Zend Technologies
with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
php -v output:
PHP 7.4.3 (cli) (built: Feb 18 2020 17:29:57) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
When I run php -m, the output is
[PHP Modules]
(a bunch of modules, but no xdebug)
[Zend Modules]
(empty)
Where do I go from here?
I would bet your php_xdebug-2.9.8-7.4-vc15-x86_64.dll is just not compatible with your PHP.
Double check if you don't see anywhere something like
Failed loading C:\xampp\php\ext\php_xdebug-2.9.8-7.4-vc15-x86_64.dll
Also check if your edited php.ini is really used by your php binary.
In my Windows box I have zend_extension=php_xdebug-2.9.8-7.4-vc15-x86_64.dll in php.ini and PHP 7.4.10 (cli) ( ZTS Visual C++ 2017 x64 ) and it works like charm.
Check NTS vs ZTS. Maybe you should use php_xdebug-2.9.8-7.4-vc15-nts-x86_64.dll

php xdebug on max sierra not working

On Mac Sierra:
I've got php 7.1 installed, and installed xdebug via:
brew install php71-xdebug
Xcode is 8.0
php -v
Cannot load Xdebug - it was already loaded
PHP 7.1.0RC3 (cli) (built: Oct 2 2016 01:05:16) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
with Xdebug v2.4.0, Copyright (c) 2002-2016, by Derick Rethans
With a phpinfo() I cannot find any text that says xdebug
The php.ini file I've tried several variations of: and restarted apache
[xdebug]
zend_extension="/usr/local/opt/php71-xdebug/xdebug.so"
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
More details can be found here: https://bugs.xdebug.org/view.php?id=1354
PHP7.1 is current not supported by xdebug, (php version <7.1). you should use 7.0 instead, and don't forget to turn on xdebog.remote_enable

How to know the xdebug version i have installed?

how to know the xdebug version i have installed?
Regards
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:
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

Resources