I've managed to get this running using phpcov (installed via composer) as mentioned:
Using Apache .htaccess to prepend/append php scripts that serialize PHP_CodeCoverage object to file, you'll need to adjust paths appropriately:
.htaccess:
# Prepend the file
php_value auto_prepend_file "prepend.php"
# Append file to bottom of page
php_value auto_append_file "append.php"
prepend.php:
<?php
require_once '../vendor/autoload.php';
$coverage = new PHP_CodeCoverage;
$coverage->start('Site coverage');
append.php:
<?php
$coverage->stop();
$cov = serialize($coverage); //serialize object to disk
file_put_contents('../cov/site.' . date('U') . '.cov', $cov);
Because I'm serializing the object I had to edit /vendor/phpunit/phpcov/src/MergeCommand.php:
protected function execute(InputInterface $input, OutputInterface $output)
{
$mergedCoverage = new PHP_CodeCoverage;
$finder = new FinderFacade(
array($input->getArgument('directory')),
array(),
array('*.cov')
);
foreach ($finder->findFiles() as $file) {
print "Merging $file" . PHP_EOL;
//$_coverage = include($file);
$_coverage = unserialize(file_get_contents($file));
$mergedCoverage->merge($_coverage);
unset($_coverage);
}
$this->handleReports($mergedCoverage, $input, $output);
}
Then using phpcov, create the report:
./vendor/bin/phpcov merge --html="./cov/report/" ./cov -vvv