Laravel for Rust Alpha
laravel-rust-barcode
Generate linear barcodes, QR Code, Data Matrix and PDF417 in Laravel for Rust.
Encode linear and matrix barcodes and render them as SVG, HTML or images. Community package, not affiliated with Laravel.
Read the docs Source on GitHub
cargo add laravel-rust-barcode- Latest release
- 0.1.0, 2026-12-05
- Maintenance
- Active
- Framework
- laravel-rust 0.2.x
- MSRV
- Rust 1.99 or later
- Licence
- MIT
PHP parity
Follows milon/barcode v13.6.0 (commit aff97c2d830c). Last verified .
- Parity level
- Full
- Abilities
- 79
- Covered
- 66
- Diverged
- 13
- Planned
- 0
- PHP fixtures
- 205
Fixtures are generated by PHP itself: PHP 8.5, illuminate/support v13.45.0, milon/barcode v13.6.0.
Coverage by ability
-
1d.c39· Covered · Core · 1 testDNS1D type C39 (Code 39) -
1d.c39_plus· Covered · 1 testDNS1D type C39+ (Code 39 with mod-43 checksum) -
1d.c39e· Covered · 1 testDNS1D type C39E (Code 39 Extended) -
1d.c39e_plus· Covered · 1 testDNS1D type C39E+ (Code 39 Extended with checksum) -
1d.c93· Covered · 1 testDNS1D type C93 (Code 93) -
1d.s25· Covered · 1 testDNS1D type S25 (Standard 2 of 5) -
1d.s25_plus· Covered · 1 testDNS1D type S25+ (Standard 2 of 5 with checksum) -
1d.i25· Covered · 1 testDNS1D type I25 (Interleaved 2 of 5) -
1d.i25_plus· Covered · 1 testDNS1D type I25+ (Interleaved 2 of 5 with checksum) -
1d.c128· Covered · Core · 1 testDNS1D type C128 (Code 128, automatic code sets A/B/C) -
1d.c128a· Covered · 1 testDNS1D type C128A (Code 128 code set A) -
1d.c128b· Covered · 1 testDNS1D type C128B (Code 128 code set B) -
1d.c128c· Covered · 1 testDNS1D type C128C (Code 128 code set C) -
1d.gs1_128· Covered · 1 testDNS1D type GS1-128 (parenthesized application identifiers) -
1d.ean2· Covered · 1 testDNS1D type EAN2 (2-digit add-on) -
1d.ean5· Covered · 1 testDNS1D type EAN5 (5-digit add-on) -
1d.ean8· Covered · 1 testDNS1D type EAN8 -
1d.ean13· Covered · Core · 1 testDNS1D type EAN13 -
1d.upca· Covered · Core · 1 testDNS1D type UPCA -
1d.upce· Covered · 1 testDNS1D type UPCE -
1d.msi· Covered · 1 testDNS1D type MSI -
1d.msi_plus· Covered · 1 testDNS1D type MSI+ (modulo-11 checksum) -
1d.postnet· Covered · 1 testDNS1D type POSTNET -
1d.planet· Covered · 1 testDNS1D type PLANET -
1d.rms4cc· Covered · 1 testDNS1D type RMS4CC (Royal Mail 4-state) -
1d.kix· Covered · 1 testDNS1D type KIX -
1d.imb· Covered · 1 testDNS1D type IMB (Intelligent Mail barcode) -
1d.codabar· Covered · 1 testDNS1D type CODABAR -
1d.code11· Covered · 1 testDNS1D type CODE11 -
1d.pharma· Covered · 1 testDNS1D type PHARMA (Pharmacode) -
1d.pharma2t· Covered · 1 testDNS1D type PHARMA2T (two-track Pharmacode) -
2d.qrcode· Covered · Core · 1 testDNS2D type QRCODE and QRCODE,L|M|Q|H -
2d.datamatrix· Covered · Core · 1 testDNS2D type DATAMATRIX -
2d.pdf417· Covered · Core · 1 testDNS2D type PDF417 and PDF417,aspect,ecc -
2d.pdf417.macro· Covered · 1 testDNS2D type PDF417,aspect,ecc,total,index,file-id,o0..o6 (Macro PDF417) -
1d.output.svg· Covered · Core · 1 testDNS1D::getBarcodeSVG(code, type, w = 2, h = 30, color = 'black', showCode = true, inline = false) -
1d.output.svg.inline· Covered · 1 testDNS1D::getBarcodeSVG(..., inline = true) omits the XML declaration and doctype -
1d.output.html· Covered · Core · 1 testDNS1D::getBarcodeHTML(code, type, w = 2, h = 30, color = 'black', showCode = 0) -
1d.output.png· Covered · Core · 1 testDNS1D::getBarcodePNG(code, type, w, h, color, showCode, bgcolor) returns base64 -
1d.output.png_path· Covered · 1 testDNS1D::getBarcodePNGPath(..., filename = null) -
1d.output.png_uri· Covered · 1 testDNS1D::getBarcodePNGUri(code, type, w, h, color) -
1d.output.jpg· Covered · 1 testDNS1D::getBarcodeJPG(code, type, w, h, color, showCode) returns base64 -
1d.output.jpg_path· Covered · 1 testDNS1D::getBarcodeJPGPath(..., filename = null) -
1d.output.jpg_uri· Covered · 1 testDNS1D::getBarcodeJPGUri(code, type, w, h, color) -
1d.hri.default· Covered · 1 test1D human-readable code under the bars (showCode, non-EAN/UPC) -
1d.hri.ean_upc· Covered · 1 testRetail EAN-8, EAN-13, UPC-A and UPC-E layout: taller guard bars and split digits -
1d.padding· Covered · 1 testDNS1D::setPadding / getPadding (quiet zone) -
1d.bgcolor· Covered · 1 testDNS1D::getBarcodePNG bgcolor (transparent by default) -
2d.output.svg· Covered · Core · 1 testDNS2D::getBarcodeSVG(code, type, w = 3, h = 3, color = 'black') -
2d.output.html· Covered · Core · 1 testDNS2D::getBarcodeHTML(code, type, w = 10, h = 10, color = 'black') -
2d.output.png· Covered · Core · 1 testDNS2D::getBarcodePNG(code, type, w, h, color, bgcolor) returns base64 -
2d.output.png_path· Covered · 1 testDNS2D::getBarcodePNGPath(..., filename = null) -
2d.output.png_uri· Covered · 1 testDNS2D::getBarcodePNGUri(code, type, w, h, color) -
2d.padding· Covered · 1 testDNS2D::setPadding / getPadding (quiet zone) -
2d.bgcolor· Covered · 1 testDNS2D::getBarcodePNG bgcolor (transparent by default) -
2d.logo· Covered · 2 testsDNS2D::setLogo(path, widthPercent) / getLogoPath (centred logo on PNG output) -
common.type_case_insensitive· Covered · 1 testBarcode type names match without regard to ASCII case (strtoupper) -
common.store_path· Covered · 1 testsetStorPath and Laravel config('barcode.store_path') -
common.store_path.temporary· DivergedImplicit temporary-directory fallback outside Laravel -
common.filename_sanitize· Covered · 1 testCustom filename: directory stripped, image extension removed, slug of the code as default -
common.error.invalid_barcode· Covered · Core · 1 testInvalidBarcodeException (unsupported type, encoding failure with a hint) -
common.error.wrong_check_digit· Covered · 1 testWrongCheckDigitException on an EAN-8, EAN-13 or UPC-A check-digit mismatch -
1d.codabar.caller_start_stop· DivergedDNS1D type CODABAR always adds A at both ends, so A1234B becomes AA1234BA -
1d.c39e.lowercase· DivergedDNS1D types C39E and C39E+ uppercase the code before the Code 39 Full ASCII expansion, so a encodes as A -
1d.c93.lowercase· DivergedDNS1D type C93 uppercases the code before expansion, so a encodes as A -
1d.vertical_tab· DivergedDNS1D types C39E, C39E+ and C93 reject byte 0x0B (InvalidBarcodeException) -
1d.two_of_five.empty· DivergedDNS1D types S25, S25+, I25 and I25+ produce a symbol for an empty payload -
common.padding.negative· DivergedPHP silently clamps negative padding to zero -
2d.qrcode.literal_backslash_zero· DivergedPHP rejects the two-byte QR payload consisting of a backslash and a zero -
1d.c128.control_runs· DivergedPHP may use one SHIFT for consecutive control characters, causing loss on decode -
common.security.markup_escape· DivergedThe code text and colour go into SVG and HTML unescaped -
common.security.bounds· DivergedUnbounded dimensions, padding and logo size -
laravel.config.store_path· Covered · 1 testconfig('barcode.store_path') (publishable config file) -
laravel.provider· Covered · Core · 1 testBarcodeServiceProvider::register / boot / provides -
laravel.facade.dns1d· Covered · Core · 1 testDNS1D facade (container singleton 'DNS1D') -
laravel.facade.dns2d· Covered · Core · 1 testDNS2D facade (container singleton 'DNS2D') -
laravel.html_safe· Covered · 1 testDocumented Blade use: {!! DNS1D::getBarcodeHTML(...) !!} -
1d.pharma.invalid· DivergedPHARMA produces a zero-width symbol for zero or non-numeric input -
2d.pdf417.macro.file_id· DivergedPHP accepts text-compacted Macro PDF417 file identifiers
Differences from PHP (13)
Implicit temporary-directory fallback outside Laravel- Framework-free callers opt in with Store::temporary(); the Laravel provider defaults to the application's public directory.
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).
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 is rejected as an invalid option (design/SPEC.md section 9.1).
PHP rejects the two-byte QR payload consisting of a backslash and a zero- The port preserves both payload bytes (design/SPEC.md section 9.1).
PHP may use one SHIFT for consecutive control characters, causing loss on decode- Automatic Code 128 latches to set A for the entire control run (design/SPEC.md section 2.7).
The code text and colour go into SVG and HTML unescaped- Labels are escaped and colours must fit the documented grammar.
Unbounded dimensions, padding and logo size- Payloads, render dimensions and logo decoding have explicit limits.
PHARMA produces a zero-width symbol for zero or non-numeric input- Invalid input returns a typed error instead of a blank symbol.
PHP accepts text-compacted Macro PDF417 file identifiers- Require one numeric file-ID codeword so standard decoders recover the caller's ID.
Built on
- milon/barcode: The PHP package whose behaviour this package independently implements, following version 13.6.0.
Crates: laravel-rust-barcode, laravel-rust-barcode-core
· Upstream notices
Documentation
- OverviewEncode linear and matrix barcodes and render them as SVG, HTML or images. Community package, not affiliated with Laravel.
- Getting startedInstall the framework-free crate and render a Code 39 symbol as SVG or HTML.
- Migrating from PHPMap milon/barcode's linear SVG and HTML calls to the Rust encoder and renderer.
- Laravel integrationAdd the adapter with cargo add laravel-rust-barcode@0.1.
- ChangelogWhat changed in each release of laravel-rust-barcode: additions, changes and fixes.