PHPackages                             dvdmarchetti/phpbarcode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dvdmarchetti/phpbarcode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

dvdmarchetti/phpbarcode
=======================

Barcodes in PHP made easy

0141PHP

Since May 8Pushed 6y ago1 watchersCompare

[ Source](https://github.com/dvdmarchetti/PHP-Barcode-Generator)[ Packagist](https://packagist.org/packages/dvdmarchetti/phpbarcode)[ RSS](/packages/dvdmarchetti-phpbarcode/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Barcode Generator
=====================

[](#php-barcode-generator)

Barcode generation made easy

### Introduction

[](#introduction)

Welcome to PHPBarcode generator. This is a PHP class which helps in barcode generation. It offers some barcode formats and options to suit your needs. Read through this documentation file to find out how to install and use the class.

### Author note

[](#author-note)

This project is based on [php-barcode](http://github.org/davidscotttufts/php-barcode) project by David Tufts. The original implementation has been made by him. My implementation it's still a work in progress and may present errors. Contributions, issues and questions are always welcome.

---

Getting Started
===============

[](#getting-started)

### Installation

[](#installation)

You may install the PHPBarcode Generator with [Composer](https://getcomposer.org/).

```
$ composer require dvdmarchetti/phpbarcode

```

### Basic Usage

[](#basic-usage)

First you have to include the composer-generated autoload file.

```

```

Then you can start generating barcodes. You just have to create a new **PHPBarcode\\Barcode** object. **PHPBarcode\\Barcode**'s constructor requires at least two parameters:

- *(IBarcodeType)* Barcode type (an object which implements **PHPBarcode\\Type\\IBarcodeType** interface)
- *(string)* Barcode text
- *(optional) (array)* Array of dimensions (with **width** and **height** index)
- *(optional) (int)* Barcode orientation (use class constants)

```
$barcode = new PHPBarcode\Barcode($type, $text);
$barcode->output();
```

This will output the image directly in your browser (displayed inline).

### Output options

[](#output-options)

There are three ways of displaying barcodes:

**1. Inline Display**

Display image directly in browser using built-in image viewer. (NOTE: This method changes **Content-Type** header to **image/png**).

Example:

```

```

**2. As Data Url**Generate a Base64Data image which can be printed into **![]()** tags.

Example:

```

```

```
