PHP client for

2.3.3 2016-04-17 08:54 UTC


Build Status Circle CI Build Status

Stories in Ready Scrutinizer Code Quality Coverage Status Dependency Status

Latest Stable Version License

CoverallsKit is the library for transmitting the report of code coverage to coveralls.
This library works with PHP5.5 or more.


  • PHP >= 5.5
  • Xdebug >= 2.2.2


Installation that uses the composer.

  1. Install the composer.

  2. Install the package.

     composer require cloak/coverallskit --dev

Basic usage

You can generate a json file using the coverallskit/CoverallsReportBuilder.
You just set the code coverage of rows that have been executed.
Code coverage can be obtained easily by using the HHVM and xdebug.

$travis = new TravisCI( new Environment($_SERVER) );
$service = new CIService($travis);

$builder = new CoverallsReportBuilder();
$builder->token('your repository token')
	->repository(new GitRepository(__DIR__ . '/../'));

$source = new SourceFile('path/to/file');
$source->addCoverage(CoverageResult::executed(1));	//The first line was executed
$source->addCoverage(CoverageResult::unused(2));	//The second line is not executed
$source->addCoverage(CoverageResult::executed(3));	//The third line is executed

$builder->build()->saveAs(__DIR__ . '/tmp/coverage.json');

Using a configuration file

If you use a configuration file, you can send the report more easily.

use coverallskit\BuilderConfiguration;
use coverallskit\CoverallsReportBuilder;

$configuration = BuilderConfiguration::loadFromFile('coveralls.toml');
$builder = CoverallsReportBuilder::fromConfiguration($configuration);

Configuration file format

It is also possible to use a configuration file.
The file format is toml format.

token = "{api-token}"
service = "travis-ci"
repositoryDirectory = "."

output = "script/coveralls.json"

type = "lcov"
file = "script/report.lcov"

File format

Name Required Default Description
token optional COVERALLS_REPO_TOKEN api token. If you do not specify, use the environment variable COVERALLS_REPO_TOKEN.
service optional travis-ci CI(Continuous Integration) service name. You can use the travis-ci or travis-pro or circle-ci or or codeship
reportFile optional Please look at the reportFile section.
repositoryDirectory optional . Directory path of the git repository. Will specify a relative path from the directory containing the configuration file.


Name Required Default Description
type optional Will specify the file type in the code coverage report. You can specify the lcov or clover.
file optional coveralls.json Will specify a file of code coverage report.

will specify the json file name to be sent to the
Will specify a relative path from the directory containing the configuration file.

Task for Robo

Support the robo of tasks, so you can easily send a report.
Please look at the robo-coveralls-kit for more information.

Detailed documentation

Run only unit test

composer test

How to run the example

vendor/bin/robo example:basic