Step 1)
Register you GitHub repo with Travis CI and Coveralls.IO.
Step 2)
In your .travis.yml file, add:
before_install: - composer require phpunit/phpunit:4.8.* satooshi/php-coveralls:dev-master - composer install --dev script: - ./vendor/bin/phpunit --coverage-clover ./tests/logs/clover.xml after_script: - php vendor/bin/coveralls -v
Where:
before_install
: Calls composer and installs PHPUnit 4.8.* + satooshi/php-coveralls.script
: Calls the installed version of PHPUnit and generates a clover.xml file in./tests/logs/clover.xml
. (This XML file will be used by PHP-Coveralls.)after_script
: Launches satooshi/php-coveralls in verbose mode.
Step 3)
Create a .coveralls.yml file that looks like:
coverage_clover: tests/logs/clover.xml json_path: tests/logs/coveralls-upload.json service_name: travis-ci
Where:
coverage_clover
: Is the path to the PHPUnit generatedclover.xml
.json_path
: Is where to output ajson_file
that will be uploaded to the Coveralls API.service_name
: Use eithertravis-ci
ortravis-pro.
Step 4)
Add badges to your GitHub README.md file.
[](https://travis-ci.org/NAMESPACE/REPO) [](https://coveralls.io/github/NAMESPACE/REPO?branch=master)
Replace NAMESPACE
and REPO
to match your GitHub repo.
Great piece. Thanks.
I could be wrong but I think composer’s –dev flag is deprecated and no longer needed.
It works. Thanks.