tklovett/barcodes

This package is abandoned and no longer maintained. The author suggests using the tecnick.com/tc-lib-barcode package instead.

Barcode generator for PHP supporting 20+ barcode types

V3.0 2014-02-24 07:03 UTC

This package is not auto-updated.

Last update: 2015-08-16 07:17:19 UTC


README

Latest Stable Version Total Downloads Build Status Coverage Status Scrutinizer Code Quality

Read More Wiki

Generating barcodes in PHP since 2015!

Generates HTML, PNG, or SVG canvas

Supported Barcode Types

One Dimensional

  • Codabar
  • Code 11
  • Code 39 (also extended and/or with check-digit)
  • Code 93
  • Code 128 (A, B, C, or Auto)
  • EAN (2, 5, 13)
  • Intelligent Mail
  • Interleave 2 of 5
  • MSI (also with check-digit)
  • Pharmacode
  • POSTNET (or PLANET)
  • RMS4CC (or KIX)
  • Standard 2 of 5 (also with check-digit)
  • UPC (A, E)

Two Dimensional

  • DataMatrix
  • PDF417
  • QR Code

Requirements

  • Barcodes requires ImageMagick to create PNGs in PHP 5.3.
  • Barcodes requires PHP bcmath extension for Intelligent Mail barcodes

Installation

You can install this package with the Composer CLI:

composer require tklovett/barcodes

Or manually add the dependency to your project's composer.json:

"require": {
    "tklovett/barcodes": "dev-master"
}

And tell composer to install it:

composer install

Usage

First instantiate a BarcodeGenerator factory:

$generator = new BarcodeGenerator();

Then tell it to generate the barcode type of your choice for your code:

$barcode = generator.generate(BarcodeType::QR_CODE, "This is what I want encoded");

Finally, output SVG, HTML, or a PNG:

$svg  = $barcode.toSVG();
$html = $barcode.toHTML();
$png  = $barcode.toPNG();

Need a custom height, width, or color for your barcode? No problem:

$width = 20;
$height = 30;
$color = 'blue';
$sizedSVG  = $barcode.toSVG($width, $height, $color);
$sizedHTML = $barcode.toSVG($width, $height, $color);
$sizedPNG  = $barcode.toSVG($width, $height, $color);

TODO:

  • Convert snake_case method names to camelCase
  • Replace returns from barcode constructors with exception throws
  • Write tests
  • Write docs
  • parent::__construct($code); in all barcodes
  • remove unused methods