A PHP package to render out package badges
This package requires PHP 5.6+
To install through composer include the package in your
composer install or
composer update to download the dependencies or you can
composer require midnite81/badges.
|StyleCI||(Image Coming soon)|
|Scrutinizer||(Image Coming soon)|
Over time support for other badges will be added. You can create your own templates which extend
Midnite81\Badges\Type\BadgeType and can be passed through the
$badges->get(MyClass::class) method. More
documentation on adding your own templates will be added later.
Firstly, you need to create an instance of badges.
use Midnite81\Badges\Badges; $badges = new Badges($attributes); // or $badges = Badges::create($attributes);
You'll notice that a variable of $attributes is passed on construction. The attributes are what the package will use to translate the template. By default we're only going to pass the following attributes as they are needed for the supported badges. Obviously update the above attributes to suit your own needs.
$attributes = [ '$PACKAGE_NAME$' => 'midnite81/badges', // Your GitHub package repo name '$STYLE_CI$' => 'repoNumber', // Your StyleCi repo number '$GITTER_ROOM$' => 'room-name' // Your gitter room name ];
Once the class is instantiated, you then need to select the type of badge you want.
$myBadge = $this->latestStableVersion();
This will return you a
Writer object, which you can call
->toMarkdown on for the final rendering
of the badge. The default
_toString method will return the html version.
So all in all;
use Midnite81\Badges\Badges; $badges = Badges::create(['$PACKAGE_NAME$' => 'midnite81/badges']); echo $badges->latestStableVersion()->toMarkdown();
[![Latest Stable Version](https://poser.pugx.org/midnite81/badges/version)](https://packagist.org/packages/midnite81/badges)