1. Go to this page and download the library: Download vitaliyboyko/pcov library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vitaliyboyko / pcov example snippets
pcov\start();
// Execute application or test code.
pcov\stop();
$coverage = pcov\collect(); // array<string, array<int, -1|1>>
pcov\clear();
$result = pcov\export(
'/path/to/bootstrap/request-1.pcov',
null,
getenv('DEPLOYMENT_ID') ?: throw new RuntimeException('Missing deployment identity')
);
if ($result === false || $result['mode'] !== 'full') {
throw new RuntimeException('Full PCOV export failed');
}
$result = pcov\export(
'/path/to/records/request-42.pcov',
'/path/to/manifests/manifest-v1.pcov',
getenv('DEPLOYMENT_ID') ?: throw new RuntimeException('Missing deployment identity')
);
if ($result === false) {
throw new RuntimeException('PCOV publication failed');
}
// "hit-only" when validation succeeds, "full-fallback" otherwise.
error_log("PCOV export mode: {$result['mode']} ({$result['reason']})");