Download the PHP package picqer/php-barcode-generator without Composer

On this page you can find all versions of the php package picqer/php-barcode-generator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?
picqer/php-barcode-generator
Rate from 1 - 5
Rated 4.25 based on 4 reviews

Informations about the package php-barcode-generator

PHP Barcode Generator

Build Status Total Downloads Latest Stable Version

This is an easy to use, non-bloated, framework independent, barcode generator in PHP. It uses zero(!) composer dependencies and is only a handful of files. Probably the reason that this is the most downloaded barcode generator for PHP on Packagist. ;)

It creates SVG, PNG, JPG and HTML images, from the most used 1D barcode standards.

No support for...

Installation

Install through composer:

If you want to generate PNG or JPG images, you need the GD library or Imagick installed on your system as well. For SVG or HTML renders, there are no dependencies.

Usage

You want a barcode for a specific "type" (for example Code 128 or UPC) in a specific image format (for example PNG or SVG).

The "type" is a standard that defines which characters you can encode and which bars represent which character. The most used types are code 128 and EAN/UPC. Not all characters can be encoded into each barcode type, and not all barcode scanners can read all types.

Will result in this beauty:

Each renderer has their own options. For example, you can set the height, width and color of a PNG:

Image renderers

Available image renderers: SVG, PNG, JPG and HTML.

They all conform to the RendererInterface and have the same render() method. Some renderers have extra options as well, via set*() methods.

Widths

The render() method needs the Barcode object, the width and height. For JPG/PNG images, you only get a valid barcode if you give a width that is a factor of the width of the Barcode object. That is why the examples show $barcode->getWidth() * 2 to make the image 2 times wider in pixels then the width of the barcode data. You can give an arbitrary number as width and the image will be scaled as best as possible, but without anti-aliasing, it will not be perfectly valid.

HTML and SVG renderers can handle any width and height, even floats.

Here are all the options for each renderer:

SVG

A vector based SVG image. Gives the best quality to print. `

PNG + JPG

All options for PNG and JPG are the same. `

HTML

Gives HTML to use inline in a full HTML document. `

Dynamic HTML

Give HTML here the barcode is using the full width and height, to put inside a container/div that has a fixed size. `

You can put the rendered HTML inside a div like this:

Accepted barcode types

These barcode types are supported. All types support different character sets and some have mandatory lengths. Please see wikipedia for supported chars and lengths per type.

You can find all supported types in the src/Types folder.

Most used types are TYPE_CODE_128 and TYPE_CODE_39. Because of the best scanner support, variable length and most chars supported.

See example images for all supported barcode types

A note about PNG and JPG images

If you want to use PNG or JPG images, you need to install Imagick or the GD library. This package will use Imagick if that is installed, or fall back to GD. If you have both installed, but you want a specific method, you can use $renderer->useGd() or $renderer->useImagick() to force your preference.

Examples

Embedded PNG image in HTML

Save JPG barcode to disk

Oneliner SVG output to disk

Upgrading to v3

There is no need to change anything when upgrading from v2 to v3. Above you find the new preferred way of using this library since v3. But the old style still works.

To give the renderers the same interface, setting colors is now always with an array of RGB colors. If you use the old BarcodeGenerator* classes and use colors with names ('red') or hex codes (#3399ef), these will be converted using the ColorHelper. All hexcodes are supported, but for names of colors only the basic colors are supported.

If you want to convert to the new style, here is an example:

The width in the renderer is now the width of the end result, instead of the widthFactor. If you want to keep dynamic widths, you can get the width of the encoded Barcode and multiply it by the widthFactor to get the same result as before. See here an example for a widthFactor of 2:


Previous style generators

In version 3 the barcode type encoders and image renderers are completely separate. This makes building your own renderer way easier. The old way was using "generators". Below are the old examples of these generators, which still works in v3 as well.

Usage

Initiate the barcode generator for the output you want, then call the ->getBarcode() routine as many times as you want.

Will result in this beauty:

The getBarcode() method accepts the following parameters:

Example of usage of all parameters:

Image types

Embedded PNG image in HTML

Save JPG barcode to disk

Oneliner SVG output to disk


The codebase is based on the TCPDF barcode generator by Nicola Asuni. This code is therefor licensed under LGPLv3.


All versions of php-barcode-generator with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package picqer/php-barcode-generator contains the following files

Loading the files please wait ....