phpbadge/phpbadge

A PHP library to create badges.

2.0.1 2019-02-22 10:24 UTC

This package is auto-updated.

Last update: 2024-04-22 20:53:21 UTC


README

Build Status Scrutinizer Code Quality Code Coverage Dependency Status SensioLabsInsight

A PHP library to build badges as seen in README's of many open source libraries.

Getting started

It's recommended to install this library via Composer.

composer require phpbadge/phpbadge

The current master branch is considered stable. The badges on top of this document should confirm this.

Requirements

As from version 2.0.0 this library needs a PHP version >= 7.1.

Older version of the library run on PHP 5.3, PHP 5.4, PHP 5.5, PHP 5.6, PHP 7 and HHVM.

Example

<?php

use PHP\Badge\Badge;
use PHP\Badge\Font\Font;
use PHP\Badge\Font\GdDimensionCalculator;
use PHP\Badge\Part;
use PHP\Badge\Renderer\SvgRenderer;

require 'vendor/autoload.php';

$badge = new Badge();
$badge->setBorderRadius(3);
$badge->addPart(new Part('build', '#555', '#fff', new Font(11, 'verdana', 'fonts/verdana.ttf')));
$badge->addPart(new Part('passing', '#4c1', '#fff', new Font(11, 'verdana', 'fonts/verdana.ttf')));

$renderer = new SvgRenderer(new GdDimensionCalculator());

echo $renderer->render($badge);