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.
Download milon/barcode
More information about milon/barcode
Files in milon/barcode
Package barcode
Short Description Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)
License LGPL-3.0
Rated 5.00 based on 1 reviews
Informations about the package barcode
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:
- 1D labels:
$w = 2–3,$h = 50–80 - QR for screen:
$w = $h = 4–8 - QR for print:
$w = $h = 8–12
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)
$color— RGB foreground[r, g, b](SVG/HTML use CSS color strings)$showCode— print human-readable text under 1D bars$bgcolor— RGB background, ornullfor transparent (default)$filename— optional custom file name for*Pathhelpers (extension optional; path segments are stripped)
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
ext-gd Version *
illuminate/support Version ^7.0|^8.0|^9.0|^10.0 | ^11.0 | ^12.0 | ^13.0