PHP: trouble trying to use PCOV instead of XDebug for Code Coverage

Hi,

this isnt directly CircleCI related but more Apache/PHP, but as maybe others will want to switch to the new fast PCOV, I thought I’d post my question here.

I am using the docker image circleci/php:7.2-apache-browsers:
- image: circleci/php:7.2-apache-browsers

This image has xDebug installed and activated (at least it should as my code coverage works).
What I am stuck at is disabling xDebug and enabling PCOV. I would like to avoid command line editing of PHP .ini files but use the much nicer functions phpenmod and phpdismod of php-common package, like:

  - run: sudo apt install php-common
  - run: sudo pecl install pcov
  - run: sudo phpdismod xdebug
  - run: sudo phpenmod pcov

While I can install php-common easily locally using sudo apt install php-common, It fails on this image:

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Package php-common is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php-common' has no installation candidate

So it seems I have to add the correct source for the package php-common. But after googling around quite a bit I still have no Idea how to find the source for that package.

Any hint on this or maybe another way to use pcov?

Best regards
Philipp

Hi,
one step further:
Enabling pcov worked using:

        sudo pecl install pcov
        sudo docker-php-ext-enable pcov

Not its only disabling pre-enabled xdebug without phpdismod working. Too bad there aint a docker-php-ext-disable :slight_smile:

Will try to just delete the xdebug.ini and see what that does. If not, other ugly hacks.

I won the fight :slight_smile:

In the end this did the job:

  - run:
      name: Enable PCOV, disable Xdebug
      command: |
        sudo pecl install pcov
        sudo docker-php-ext-enable pcov
        sudo rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini

PCOV definitely holds its promises. My tests run more than twice as fast now getting the same coverage results. Very nice.

1 Like

In case anyone ends up here trying to set up pcov like I did, and runs into an error like this:

docker-php-ext-enable: 108: docker-php-ext-enable: cannot create /conf.d/XXXXXX.ini: Directory nonexistent

add the -E flag, as mentioned in https://support.circleci.com/hc/en-us/articles/360012768473-docker-php-ext-enable-108-docker-php-ext-enable-cannot-create-conf-d-XXXXXX-ini-Directory-nonexistent

Welcome to our Discuss board! I am glad to hear you found this Support Article helpful!