Download the PHP package milon/barcode without Composer

On this page you can find all versions of the php package milon/barcode. 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?
milon/barcode
Rate from 1 - 5
Rated 5.00 based on 1 reviews

Informations about the package barcode

Packagist Downloads Stable version License Tests

Barcode generation for Laravel and plain PHP. This package wraps the TCPDF barcode engines (1D + QR / Data Matrix / PDF417) behind a small API that returns SVG, HTML, PNG, and JPEG.

Requires the PHP GD extension (ext-gd).

Full docs: oss.milon.im/barcode

Examples below are real outputs from this library. Regenerate them with:


Installation

Laravel compatibility

Laravel Package
13.* ^13.0
12.* ^12.0
11.* ^11.0
10.* ^10.0
9.* ^9.0
8.* ^8.0
7.* ^7.0
6.* ^6.0
5.0–5.1 ^5.1
4.x ^4.2

Laravel 6+ auto-discovers the service provider and facades (DNS1D, DNS2D).

Publish config (optional)

Default store path is the Laravel storage directory (used by *Path helpers). Ensure the directory is writable.


Quick start

Blade

Always use {!! !!} (unescaped). PNG helpers return raw base64, not a full data: URL:


Units: $w and $h

API $w $h
DNS1D (1D) Width of a single bar in pixels Total barcode height in pixels
DNS2D (QR / DM / PDF417) Width of a module in pixels Height of a module in pixels

Larger $w / $h = larger image. Typical starting points:


Output methods

Method Returns
getBarcodeSVG(...) SVG markup string
getBarcodeHTML(...) HTML (div/span) markup
getBarcodePNG(...) Base64-encoded PNG
getBarcodeJPG(...) Base64-encoded JPEG (1D)
getBarcodePNGPath(...) Relative path to a PNG written under the store path
getBarcodeJPGPath(...) Relative path to a JPEG written under the store path (1D)

Common options

1D (DNS1D)

2D (DNS2D)

Quiet zone (padding) for print / scanners

Printed barcodes often fail to scan when bars sit flush against the page edge or other graphics. Add a quiet zone with setPadding() (pixels on every side):

SVG output also sets shape-rendering="crispEdges" to reduce print-time anti-alias blur.

QR logo (centered)

Overlay a logo on QR / Datamatrix PNG output (GD). Use high error correction (QRCODE,H) and keep the logo modest (~15–25% of width) so scanners still read the code.

Retail UPC-A / EAN layout

EAN-8, EAN-13, UPC-A, and UPC-E now use taller guard bars and, when $showCode is enabled, split human-readable digits (number system / left / right / check) instead of one centered string.


Background color (dark UI / email)

Transparent PNGs disappear on dark backgrounds. Pass a white (or light) $bgcolor:

Transparent (default) White background


Examples (with screenshots)

CODE 39

CODE 39+

CODE 128

CODE 128A / 128B / 128C

C128A C128B C128C

EAN-13 / EAN-8 / UPC-A

EAN-13 EAN-8 UPC-A

Interleaved 2 of 5 / Codabar / Pharmacode

I25 Codabar Pharmacode

Custom bar color

QR Code / Data Matrix / PDF417

QR Code Data Matrix PDF417

Browse all generated samples: docs/examples/gallery.html

Regenerate images + gallery:


Symbology character sets

Invalid input throws Milon\Barcode\InvalidBarcodeException with a hint for the chosen type.

Type Allowed data (practical)
C39 0-9 A-Z space and -.$/+%
C39E / C39E+ Full ASCII (extended CODE 39)
C128 Full ASCII; auto code-set
C128A Uppercase / control; no lowercase — use C128B or C128
C128B Full ASCII
C128C Digits only, encoded in pairs (even length)
EAN13 12–13 digits (check digit calculated/validated)
EAN8 7–8 digits
UPCA 11–12 digits
UPCE Compressed UPC-E digit form
I25 / S25 Digits (I25 prefers even length)
CODABAR Digits plus -$:/.+ with A–D start/stop
PHARMA Numeric pharmacode
QRCODE Text/URL; capacity depends on version/ECC
DATAMATRIX Text; capacity depends on symbol size
PDF417 Longer text payloads

Prefer C128 (auto) unless you specifically need A/B/C.

Also supported (1D)

C39+, C93, S25, S25+, I25+, GS1-128, EAN2, EAN5, MSI, MSI+, POSTNET, PLANET, RMS4CC, KIX, IMB, CODE11, PHARMA2T


Standalone PHP (no Laravel)

Laravel is optional. Without a container, the store path defaults to the system temp directory (or whatever you set):

Use the instance API (or the Laravel facade). Calling DNS2D::getBarcodePNG() as a static method on the class itself will not work.


FAQ

Why is my Blade barcode empty / escaped HTML?
Use {!! DNS1D::getBarcodeHTML(...) !!}, not {{ }}.

Why is the <img> broken?
PNG helpers return base64 only. Prefix with data:image/png;base64,.

Barcode works in light mode but not dark mode / email?
Pass a solid $bgcolor, e.g. [255, 255, 255].

Printed barcode won’t scan reliably?
Add a quiet zone (setPadding(...)), use a larger $w (avoid $w = 1 for print), and prefer SVG/PNG over scaled-down screen captures. See Quiet zone.

InvalidBarcodeException?
The payload does not match the symbology (see table above). Switch type or sanitize input.

Can this package scan barcodes from a camera?
No. It only generates barcodes. Scanning needs a separate library or device SDK.

Can it authenticate users / replace login?
No. Generating a QR of a URL or token is not authentication by itself.


License

GNU LGPLv3. Copyright Nuruzzaman Milon. Original barcode classes by Nicola Asuni / Tecnick.com LTD (TCPDF).

Buy me a coffee


All versions of barcode with dependencies

PHP Build Version
Package Version
Requires php Version ^7.3 | ^8.0
ext-gd Version *
illuminate/support Version ^7.0|^8.0|^9.0|^10.0 | ^11.0 | ^12.0 | ^13.0
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 milon/barcode contains the following files

Loading the files please wait ...