Laravel for Go Alpha

laravel-go-barcode

Generate linear barcodes, QR codes, Data Matrix and PDF417 in Go and Laravel for Go, with SVG, HTML, PNG and JPEG outputs.

Go port of milon/barcode: generate 1D and 2D barcodes as SVG, HTML and PNG, and 1D barcodes as JPEG, for Go and Laravel for Go.

Read the docs Source on GitHub

go get github.com/bowerbird-si/laravel-go-barcode@v0.1.0
Latest release
0.1.0, 2026-12-05
Maintenance
Active
Framework
go.laravel.com v0.2.0 or later
Go
Go 1.27.0 or later
Licence
MIT

PHP parity

Follows milon/barcode v13.6.0 (commit aff97c2d830c). Last verified .

Parity level
Full
Abilities
75
Covered
62
Diverged
13
Planned
0
PHP fixtures
205
Coverage by ability
  • 1d.c39 · Covered · Core · 2 tests
    DNS1D type C39 (Code 39)
  • 1d.c39_plus · Covered · 2 tests
    DNS1D type C39+ (Code 39 with mod-43 checksum)
  • 1d.c39e · Covered · 3 tests
    DNS1D type C39E (Code 39 Extended)
  • 1d.c39e_plus · Covered · 3 tests
    DNS1D type C39E+ (Code 39 Extended with checksum)
  • 1d.c93 · Covered · 3 tests
    DNS1D type C93 (Code 93)
  • 1d.s25 · Covered · 3 tests
    DNS1D type S25 (Standard 2 of 5)
  • 1d.s25_plus · Covered · 3 tests
    DNS1D type S25+ (Standard 2 of 5 with checksum)
  • 1d.i25 · Covered · 3 tests
    DNS1D type I25 (Interleaved 2 of 5)
  • 1d.i25_plus · Covered · 3 tests
    DNS1D type I25+ (Interleaved 2 of 5 with checksum)
  • 1d.c128 · Diverged · Core
    DNS1D type C128 (Code 128, automatic code sets A/B/C)
  • 1d.c128a · Covered · 2 tests
    DNS1D type C128A (Code 128 code set A)
  • 1d.c128b · Covered · 2 tests
    DNS1D type C128B (Code 128 code set B)
  • 1d.c128c · Covered · 3 tests
    DNS1D type C128C (Code 128 code set C)
  • 1d.gs1_128 · Covered · 3 tests
    DNS1D type GS1-128 (parenthesized application identifiers)
  • 1d.ean2 · Covered · 3 tests
    DNS1D type EAN2 (2-digit add-on)
  • 1d.ean5 · Covered · 2 tests
    DNS1D type EAN5 (5-digit add-on)
  • 1d.ean8 · Covered · 3 tests
    DNS1D type EAN8
  • 1d.ean13 · Covered · Core · 3 tests
    DNS1D type EAN13
  • 1d.upca · Covered · Core · 3 tests
    DNS1D type UPCA
  • 1d.upce · Covered · 3 tests
    DNS1D type UPCE
  • 1d.msi · Covered · 2 tests
    DNS1D type MSI
  • 1d.msi_plus · Covered · 3 tests
    DNS1D type MSI+ (modulo-11 checksum)
  • 1d.postnet · Covered · 3 tests
    DNS1D type POSTNET
  • 1d.planet · Covered · 2 tests
    DNS1D type PLANET
  • 1d.rms4cc · Covered · 2 tests
    DNS1D type RMS4CC (Royal Mail 4-state)
  • 1d.kix · Covered · 2 tests
    DNS1D type KIX
  • 1d.imb · Covered · 3 tests
    DNS1D type IMB (Intelligent Mail barcode)
  • 1d.codabar · Covered · 3 tests
    DNS1D type CODABAR
  • 1d.code11 · Covered · 3 tests
    DNS1D type CODE11
  • 1d.pharma · Covered · 3 tests
    DNS1D type PHARMA (Pharmacode)
  • 1d.pharma2t · Covered · 3 tests
    DNS1D type PHARMA2T (two-track Pharmacode)
  • 2d.qrcode · Covered · Core · 2 tests
    DNS2D type QRCODE and QRCODE,L|M|Q|H
  • 2d.datamatrix · Covered · Core · 2 tests
    DNS2D type DATAMATRIX
  • 2d.pdf417 · Covered · Core · 2 tests
    DNS2D type PDF417 and PDF417,aspect,ecc
  • 2d.pdf417.macro · Covered · 3 tests
    DNS2D type PDF417,aspect,ecc,total,index,file-id,o0..o6 (Macro PDF417)
  • 1d.output.svg · Covered · Core · 1 test
    DNS1D::getBarcodeSVG(code, type, w = 2, h = 30, color = 'black', showCode = true, inline = false)
  • 1d.output.svg.inline · Covered · 1 test
    DNS1D::getBarcodeSVG(..., inline = true) omits the XML declaration and doctype
  • 1d.output.html · Covered · Core · 1 test
    DNS1D::getBarcodeHTML(code, type, w = 2, h = 30, color = 'black', showCode = 0)
  • 1d.output.png · Covered · Core · 1 test
    DNS1D::getBarcodePNG(code, type, w, h, color, showCode, bgcolor) returns base64
  • 1d.output.png_path · Covered · 1 test
    DNS1D::getBarcodePNGPath(..., filename = null)
  • 1d.output.png_uri · Covered · 1 test
    DNS1D::getBarcodePNGUri(code, type, w, h, color)
  • 1d.output.jpg · Covered · 2 tests
    DNS1D::getBarcodeJPG(code, type, w, h, color, showCode) returns base64
  • 1d.output.jpg_path · Covered · 1 test
    DNS1D::getBarcodeJPGPath(..., filename = null)
  • 1d.output.jpg_uri · Covered · 1 test
    DNS1D::getBarcodeJPGUri(code, type, w, h, color)
  • 1d.hri.default · Diverged
    1D human-readable code under the bars (showCode, non-EAN/UPC)
  • 1d.hri.ean_upc · Covered · 3 tests
    Retail EAN-8, EAN-13, UPC-A and UPC-E layout: taller guard bars and split digits
  • 1d.padding · Covered · 3 tests
    DNS1D::setPadding / getPadding (quiet zone)
  • 1d.bgcolor · Covered · 1 test
    DNS1D::getBarcodePNG bgcolor (transparent by default)
  • 2d.output.svg · Covered · Core · 1 test
    DNS2D::getBarcodeSVG(code, type, w = 3, h = 3, color = 'black')
  • 2d.output.html · Covered · Core · 1 test
    DNS2D::getBarcodeHTML(code, type, w = 10, h = 10, color = 'black')
  • 2d.output.png · Covered · Core · 2 tests
    DNS2D::getBarcodePNG(code, type, w, h, color, bgcolor) returns base64
  • 2d.output.png_path · Covered · 2 tests
    DNS2D::getBarcodePNGPath(..., filename = null)
  • 2d.output.png_uri · Covered · 1 test
    DNS2D::getBarcodePNGUri(code, type, w, h, color)
  • 2d.padding · Covered · 1 test
    DNS2D::setPadding / getPadding (quiet zone)
  • 2d.bgcolor · Covered · 1 test
    DNS2D::getBarcodePNG bgcolor (transparent by default)
  • 2d.logo · Covered · 2 tests
    DNS2D::setLogo(path, widthPercent) / getLogoPath (centred logo on PNG output)
  • common.type_case_insensitive · Covered · 3 tests
    Barcode type names match without regard to ASCII case (strtoupper)
  • common.store_path · Covered · 2 tests
    setStorPath, config('barcode.store_path') and the temp-directory fallback
  • common.filename_sanitize · Diverged
    Custom filename: directory stripped, image extension removed, slug of the code as default
  • common.error.invalid_barcode · Covered · Core · 3 tests
    InvalidBarcodeException (unsupported type, encoding failure with a hint)
  • common.error.wrong_check_digit · Covered · 2 tests
    WrongCheckDigitException on an EAN-8, EAN-13 or UPC-A check-digit mismatch
  • 1d.codabar.caller_start_stop · Diverged
    DNS1D type CODABAR always adds A at both ends, so A1234B becomes AA1234BA
  • 1d.c39e.lowercase · Diverged
    DNS1D types C39E and C39E+ uppercase the code before the Code 39 Full ASCII expansion, so a encodes as A
  • 1d.c93.lowercase · Diverged
    DNS1D type C93 uppercases the code before expansion, so a encodes as A
  • 1d.vertical_tab · Diverged
    DNS1D types C39E, C39E+ and C93 reject byte 0x0B (InvalidBarcodeException)
  • common.security.markup_escape · Diverged
    The code text and colour go into SVG and HTML unescaped
  • common.security.bounds · Diverged
    Unbounded dimensions, padding and logo size
  • laravel.config.store_path · Diverged
    config('barcode.store_path') (publishable config file)
  • laravel.provider · Covered · Core · 1 test
    BarcodeServiceProvider::register / boot / provides
  • laravel.facade.dns1d · Covered · Core · 1 test
    DNS1D facade (container singleton 'DNS1D')
  • laravel.facade.dns2d · Covered · Core · 1 test
    DNS2D facade (container singleton 'DNS2D')
  • laravel.html_safe · Covered · 1 test
    Documented Blade use: {!! DNS1D::getBarcodeHTML(...) !!}
  • 1d.two_of_five.empty · Diverged
    DNS1D types S25, S25+, I25 and I25+ produce a symbol for an empty payload
  • common.padding.negative · Diverged
    PHP silently clamps negative padding to zero
  • 2d.qrcode.literal_backslash_zero · Diverged
    PHP rejects the two-byte QR payload consisting of a backslash and a zero
Differences from PHP (13)
DNS1D type C128 (Code 128, automatic code sets A/B/C)
A Code A latch preserves every byte in a multi-character control run.
1D human-readable code under the bars (showCode, non-EAN/UPC)
Go rejects labels that cannot fit the requested height.
Custom filename: directory stripped, image extension removed, slug of the code as default
Go follows ASCII slug rules and transliterates Latin-1 and Latin Extended-A letters.
DNS1D type CODABAR always adds A at both ends, so A1234B becomes AA1234BA
A letter A-D at the first or last position is that end's start or stop character; A is added only where it is missing, and A-D elsewhere is an error. PHP adds A even when an end already has a letter and accepts letters inside the code (design/decisions/0001).
DNS1D types C39E and C39E+ uppercase the code before the Code 39 Full ASCII expansion, so a encodes as A
No uppercasing before the expansion: lowercase uses the ISO/IEC 16388 Annex A plus-shift, so the scanner reads back the caller's text (design/decisions/0001).
DNS1D type C93 uppercases the code before expansion, so a encodes as A
No uppercasing: lowercase uses the dedicated plus shift in Code 93, so the scanner reads back the caller's text (design/decisions/0001).
DNS1D types C39E, C39E+ and C93 reject byte 0x0B (InvalidBarcodeException)
Byte 0x0B is encoded as ISO/IEC 16388 Annex A and Code 93 define it, with the dollar shift followed by K, instead of being rejected because of a defect in PHP's expansion table (design/decisions/0001).
The code text and colour go into SVG and HTML unescaped
Rendered labels are escaped and CSS colors are validated before interpolation.
Unbounded dimensions, padding and logo size
Input sizes, render dimensions and logo sizes are bounded before encoding or raster allocation.
config('barcode.store_path') (publishable config file)
Laravel for Go takes an existing store directory through the programmatic StoreDir option.
DNS1D types S25, S25+, I25 and I25+ produce a symbol for an empty payload
Both ports require at least one input digit, including the check-digit variants (design/SPEC.md section 1.3).
PHP silently clamps negative padding to zero
Negative padding returns ErrInvalidOption.
PHP rejects the two-byte QR payload consisting of a backslash and a zero
Both bytes are ordinary payload and must round-trip.

Built on

  • milon/barcode: Reference behaviour for this independent Go implementation, following version 13.6.0.

Go modules: github.com/bowerbird-si/laravel-go-barcode · Upstream notices

Documentation