PHPUnit gives No Code Coverage Driver Is Available - xdebug

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

Related

Undefined subroutine &main::open_quote called at /usr/local/bin/autom4te line 262

Hi I try to install xdebug via pecl on macox (Big Sur 11.5.2)
But I get error message
xdebug volodymyr$ pecl install xdebug
downloading xdebug-3.0.4.tgz ...
Starting to download xdebug-3.0.4.tgz (215,870 bytes)
.............................................done: 215,870 bytes
87 source files, building
running: phpize
Configuring for:
PHP Api Version: 20190902
Zend Module Api No: 20190902
Zend Extension Api No: 320190902
Undefined subroutine &main::open_quote called at /usr/local/bin/autom4te line 262.
ERROR: `phpize' failed
I update perl but it did help me (I can't catch if the open_quote is a part of perl)
Also I didn't find any information in the internet that is related with open_quote function issue
I tried to install xdebug from source and get the same bug on the ./phpize step
Resolve:
Just reinstall autoconf automake libtool
I run
brew reinstall autoconf automake libtool
After that I run brew link --force autoconf and it resolved the trouble
The error here comes from autom4te, not pecl or ./phpize. You need to update automake and autoconf, and/or related packages.

Problem installing/rebuilding Xdebug under Apple Silicon M1

Failing to install XDebug under the new Apple Silicon M1 under Big Sur - After using pecl install xdebug and running php --ini I am getting the following error:
PHP Warning: Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found. Did find:
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0
Warning: Failed loading Zend extension 'xdebug.so' (tried: /opt/homebrew/lib/php/pecl/20190902/xdebug.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so, 9): no suitable image found. Did find:
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: mach-o, but wrong architecture
/opt/homebrew/lib/php/pecl/20190902/xdebug.so: stat() failed with errno=22), /opt/homebrew/lib/php/pecl/20190902/xdebug.so.so (dlopen(/opt/homebrew/lib/php/pecl/20190902/xdebug.so.so, 9): image not found)) in Unknown on line 0
I tried recompiling xdebug from source (git clone git://github.com/xdebug/xdebug.git) with the same results. Can I force the correct architecture in the config.m4 when recompiling xdebug? - ANy other suggestions?
I needed to specify the architecture.
It worked with :
arch -arm64 sudo pecl install xdebug
tried install with pecl install xdebug and got this error:
Build process completed successfully
Installing '/opt/homebrew/Cellar/php#7.4/7.4.15_1/pecl/20190902/xdebug.so'
Warning: mkdir(): File exists in System.php on line 294
Warning: mkdir(): File exists in /opt/homebrew/Cellar/php#7.4/7.4.15_1/share/php#7.4/pear/System.php on line 294
ERROR: failed to mkdir /opt/homebrew/Cellar/php#7.4/7.4.15_1/pecl/20190902
I used fix from this link https://patriqueouimet.ca/tip/installing-php-and-pecl-extensions-on-macos and it helped
Your warnings are about architecture, maybe need to remove and install again - i was do all from arm64 terminal...
Simply open your php.ini file and replace this line:
zend_extension="xdebug.so"
with whatever the installation process offered you
in my case it's:
/opt/homebrew/Cellar/php/8.1.5/pecl/20210902/xdebug.so
And remember to restart your services!
On a fresh MacOS installation I was getting an error:
Warning: mkdir(): File exists in System.php on line 294 PHP Warning: mkdir(): File exists in /usr/local/Cellar/php/7.3.3/share/php/pear/System.php on line 294
Warning: mkdir(): File exists in /usr/local/Cellar/php/7.3.3/share/php/pear/System.php on line 294 ERROR: failed to mkdir /usr/local/Cellar/php/7.3.3/pecl/20180731
You simply need to make the directory the script cannot, to accomplish this, run the following:
pecl config-get ext_dir | pbcopy
mkdir -p {paste clipboard value}
Now you can install PECL extensions
pecl install xdebug
You will likely have to install Xdebug through PECL with:
arch -x86_64 sudo pecl install xdebug
Not sure if this was the problem. However, I did a full reset of my M1 Macbook. And this time I only used arm software (iterm, homebrew...), this time it installed without any issue.

xdebug for php 7 on ubuntu 14.04

I'm trying to get xdebug working on PHP 7. I'm build the xdebug.so file from version http://xdebug.org/files/xdebug-2.4.0rc4.tgz. The phpize output looks correct (Zend Extension Api No: 320151012) however I get Xdebug requires Zend Engine API version 220121212. from PHP.
So I've followed these instructions:
Tailored Installation Instructions
Summary
Xdebug installed: no Server API: Apache 2.0 Handler Windows: no Zend
Server: no PHP Version: 7.0.9-1 Zend API nr: 320151012 PHP API nr:
20151012 Debug Build: no Thread Safe Build: no Configuration File
Path: /etc/php/7.0/apache2 Configuration File:
/etc/php/7.0/apache2/php.ini Extensions directory:
/usr/lib/php/20151012 Instructions
Download xdebug-2.4.1.tgz Unpack the downloaded file with tar -xvzf
xdebug-2.4.1.tgz Run: cd xdebug-2.4.1 Run: phpize (See the FAQ if you
don't have phpize.
As part of its output it should show:
Configuring for: ... Zend Module Api No: 20151012 Zend Extension
Api No: 320151012 If it does not, you are using the wrong phpize.
Please follow this FAQ entry and skip the next step.
Run: ./configure Run: make Run: cp modules/xdebug.so
/usr/lib/php/20151012 Edit /etc/php/7.0/apache2/php.ini and add the
line zend_extension = /usr/lib/php/20151012/xdebug.so Restart the
webserver
With the exception that I've installed php7.0-dev instead of php5 apt-get install -y php7.0-dev.
When I run the phpize command I get the following output:
Configuring for:
PHP Api Version: 20151012
Zend Module Api No: 20151012
Zend Extension Api No: 320151012
As expected. However when I run PHP I get:
Xdebug requires Zend Engine API version 220121212.
The Zend Engine API version 320151012 which is installed, is newer.
Contact Derick Rethans at http://xdebug.org/docs/faq#api for a later
version of Xdebug.
I'm obviously doing something wrong somewhere! Any help on debugging the issue is very appreciated! :)
So I fixed this by using the apt-get package:
apt-get install -y php-xdebug
This seems to install the correct xdebug.so file and everything is working!

Not able build apache mod_tile in openSuse error: Could not find apxs on the path

I want to run a tiles server with OSM data
i want to install mod_tile so i followed the mod_tile setup
But when i do the
./configure
It says
checking for getloadavg... yes
checking for apxs... no
checking for apxs2... no
checking for /opt/local/apache2/bin/apxs... no
configure: error: Could not find apxs on the path.
any idea what went wrong?
According to the Internets you need to install apache2-dev (previously known as apache2-devel). The apx binary should then be located under /usr/bin/apxs2 or /usr/sbin/apxs2.
Note: For building a tile server you should follow the guide on switch2osm.
For Ubuntu
sudo apt-get install apache2-devel
For RedHat & CentOs
yum install httpd-devel
SUSE has removed the SDK ISO from the area where you download the server ISO.
Check out this page.
I consider their page as very complicated and not logical so play a bit around but you find it in the end.
When you are looking for a current version then it helps you check Last 6 months

Mac Ports Update Failing

hansarijanto$ port -v
MacPorts 2.0.3
hansarijanto$ xcodebuild -version
Xcode 4.3.2
Build version 4E2002
I am running the above xcode and macport version. on max os x
when I try to self update my mac port I get the following error.
hansarijanto$ sudo port selfupdate
Password:
---> Updating MacPorts base sources using rsync
MacPorts base version 2.0.3 installed,
MacPorts base version 2.0.4 downloaded.
---> Updating the ports tree
---> MacPorts base is outdated, installing new version 2.0.4
Installing new MacPorts release in /opt/local as root:admin; permissions 0755; Tcl-Package in /Library/Tcl
Error: /opt/local/bin/port: port selfupdate failed: Error installing new MacPorts base: shell command failed (see log for details)
I am trying to update mac port to install qt.
sudo port install qt4-mac-devel(error no SDK found)
which I need to install webkit-capybara
sudo gem install capybara-webkit -v '0.7.2'(error in setting up native environment)
You need to use the -d option to get enough information to diagnose this; but take a look at https://trac.macports.org/wiki/FAQ#selfupdatefails for common problems and solutions.
Seems Apple no longer installs Xcode's command line tools. See here: http://ericwilson.erics.ws/ericsblog/2012/8/26/macports-port-selfupdate-fail for solution.
Just wanted to add that on Mac OS 10.12 Sierra i was getting the WARNING: GNUSTEP_SYSTEM_ROOT is not defined error on selfupdate and i did already have the Xcode command line tools installed, licensed and working. But my copy of Xcode had become out of date, even though that was not showing up on the automatic software updates.
I had version 7 and for Sierra (and macports) you need version 8.
So I manually downloaded Xcode 8 via the App Store and it solved the problem for me.

Resources