GitHub badges ! (PHP repository)

Disclaimer : If you don't know what are badges I'd suggest a quick view to which is a open source project with badges for PHP projects. Also for this post I'm assume you have a experience with GitHub already and know how to commit, push, pull or use GitHub from web interface.

Repository used for this post you can find here.

Badgest we're going to use:

- Build Status
- Coverage Status
- Total Downloads
- Latest Stable Version
- Latest Unstable Version
- License

Final result

GitHub badges

Travis CI

First step is go to and click in Sign in with GitHub and Travis will ask you to sign with your GitHub account. Fill the fields Username/Email and Password and click in sign in (Don't forget to allow Travis in your GitHub account).

Now we have to go to our profile in Travis and enable which repository we're going to build.

Travis CI repository list

If you have any issue doing this follow the step in travis CI website!


We have to tell Travis which configuration we're going to use and to do that we use a file called .travis.yml and push it to the root of the repository.

language: php

  - 5.3
  - 5.4
  - 5.5
  - 5.6
  - hhvm

  - composer install

The last step to use the Build Badge is update the file in your GitHub repository.

Getting link to the badge

1) click on Build Passing in the left side of your repository name and a modal will appear.
2) Select which branch you're going to use
3) Select Markdown in the select box
4) Copy the text in the text area
5) Create a file in your repository called (or just update it if exists) with the copied text in the step 4.


To use coverage badge we're going to use and as we did with Travis we have to allow coveralls in our GitHub account. Go to and click in Free GitHub Sign-in.

After a successful login click in add repos.

Adding repositories in

Just like Travis select which one you're going yo use.

Coveralls repository list


To use you must have a test suite. Here we're going to use phpunit to execute our tests.

We must update our .travis.yml file to execute our tests and generate coverage in a XML format for

language: php

  - 5.3
  - 5.4
  - 5.5
  - 5.6
  - hhvm

  - composer install

  - mkdir -p build/logs 
  - phpunit --coverage-clover build/logs/clover.xml

  - php vendor/bin/coveralls -v

As you can see we add some extra tasks to Travis, just update yours .travis.yml and push it to the repository.


To get coveralls working correctly we should create a file called .coveralls.yml with the following content:

src_dir: .

After that push it to your repository.

Otherwise you'll get a InvalidArgumentException from Travis build:

Coveralls error

Now we have Travis working together with We need just to update our with the badge.

Coveralls report

1) Go to

2) Select your repository in the list

3) In the rightmost look at the bottom and find Readme Badge and click on it.

4) Wen the pop-up shows select the Markdown text

5) Update your on GitHub with this text

Total Downloads, Latest Stable Version, Latest Unstable Version, License

Now we have our two badges(Build with Travis and Code Coverage with Coveralls) in our repository, but we have 4 badges to be done yet.

The reason I left those for last is simple you can find them in

IMPORTANT ! Your repository must be in otherwise it wont work.

1) Type your repository name in the text box
2) Select which you want to and select the Markdown text or click in Copy to clipboard
3) Update your in your repository

Poser website


InvalidArgumentException with Coveralls -

Adding Build Badge with Travis -

About the author Articles Calendar Conferences and Talks Newbie's guide Resources Tests