Laravel for Rust Alpha

laravel-rust-qrcode

QR codes for routes, templates, and files.

Serve a QR image from a Laravel route, put it in a MiniJinja view, or render it with the standalone Rust core. The encoder and renderers are checked against fixtures produced by Simple QrCode 4.2.0.

Read the docs Source on GitHub

cargo add laravel-rust-qrcode@0.1.0
Latest release
0.1.0, 2026-12-04
Maintenance
Active
Framework
laravel-rust 0.2.x
MSRV
Rust 1.99 or later
Licence
MIT

PHP parity

Follows simplesoftwareio/simple-qrcode 4.2.0 (commit 916db7948ca6). Last verified .

Parity level
Core
Abilities
50
Covered
13
Diverged
19
Planned
18
PHP fixtures
83

Fixtures are generated by PHP itself: PHP 8.4, bacon/bacon-qr-code 2.0.8, dasprid/enum 1.0.7, simplesoftwareio/simple-qrcode 4.2.0.

Coverage by ability
  • generate · Covered · Core · 1 test
    Generator::generate and Writer defaults
  • generate.file · Covered · 1 test
    Generator::generate with filename
  • format.svg · Covered · Core · 1 test
    Generator::format('svg')
  • format.png · Covered · Core · 1 test
    Generator::format('png')
  • format.eps · Covered · 1 test
    Generator::format('eps')
  • format.invalid · Covered · 1 test
    Generator::format validation
  • size · Diverged · Core
    Generator::size
  • margin · Diverged · Core
    Generator::margin
  • correction · Covered · Core · 2 tests
    Generator::errorCorrection
  • encoding · Diverged
    Generator::encoding
  • matrix.auto · Diverged · Core
    Writer automatic encoding policy
  • color.foreground · Diverged
    Generator::color
  • color.background · Diverged
    Generator::backgroundColor
  • color.create · Diverged
    Generator::createColor
  • gradient · Planned
    Generator::gradient
  • style · Planned
    Generator::style
  • eye · Planned
    Generator::eye
  • eye.color · Planned
    Generator::eyeColor
  • merge.file · Planned
    Generator::merge
  • merge.bytes · Planned
    Generator::mergeString
  • merge.format · Planned
    Generator PNG-only merge
  • image.decode · Planned
    Image::__construct
  • image.width · Planned
    Image::getWidth
  • image.height · Planned
    Image::getHeight
  • image.get · Planned
    Image::getImageResource
  • image.set · Planned
    Image::setImageResource
  • image.merge.new · Planned
    ImageMerge::__construct
  • image.merge · Planned
    ImageMerge::merge
  • renderer.writer · Covered · 1 test
    Generator::getWriter
  • renderer.get · Covered · 1 test
    Generator::getRenderer
  • renderer.style · Planned
    Generator::getRendererStyle
  • renderer.format · Diverged
    Generator::getFormatter
  • renderer.module · Planned
    Generator::getModule
  • renderer.eye · Planned
    Generator::getEye
  • renderer.fill · Planned
    Generator::getFill
  • helper.email · Diverged
    Generator::email and Email
  • helper.geo · Diverged
    Generator::geo and Geo
  • helper.phone · Covered · 1 test
    Generator::phoneNumber and PhoneNumber
  • helper.sms · Diverged
    Generator::SMS and SMS
  • helper.wifi · Diverged
    Generator::wiFi and WiFi
  • helper.btc · Diverged
    Generator::BTC and BTC
  • helper.dispatch · Diverged
    Generator::__call and DataTypeInterface
  • laravel.provider.register · Diverged
    QrCodeServiceProvider::register and Composer discovery
  • laravel.provider.provides · Diverged
    QrCodeServiceProvider::provides
  • laravel.facade · Covered · 1 test
    QrCode facade alias and cache clear
  • laravel.html · Covered · Core · 1 test
    Generator::generate HtmlString and documented Blade use
  • laravel.image · Covered · 1 test
    Documented email embed and base64 PNG
  • encoding.shift-jis · Diverged
    Bacon Shift-JIS dispatch and aliases
  • encoding.invalid · Diverged
    Unknown and nonexistent encoding labels
  • generate.text · Diverged
    UTF-8 input to the PHP writer
Differences from PHP (19)
Generator::size
The canvas is bounded to 4096 pixels or points, and PNG needs at least one pixel per module. PHP delegates invalid and resource-intensive dimensions to the backend.
Generator::margin
The margin is nonnegative and capped at 64 modules per side before rendering. PHP forwards the raw integer to the backend.
Generator::encoding
Rust supports the listed character sets except nonexistent ISO-8859-12. Its converters follow Unicode mappings that can accept extensions PHP iconv rejects, such as EUC-KR extensions and Windows-1252 C1 controls. The parser also rejects labels outside the listed set, including BIG5.
Writer automatic encoding policy
The Rust encoder can choose a smaller fitting version or a different standard mask. Controlled version and mask reproduce the PHP modules when the encoded bytes, mode, ECI, and error-correction level match. An independent decoder recovers the same bytes.
Generator::color
SVG and PNG support alpha. EPS composites partial alpha onto white. PHP can instead discard alpha or fail while converting an alpha-wrapped black to CMYK.
Generator::backgroundColor
SVG and PNG support alpha. EPS composites partial alpha onto white. PHP can instead discard alpha or fail while converting an alpha-wrapped black to CMYK.
Generator::createColor
The native color type takes RGB and alpha bytes. PHP uses RGB bytes with an optional 0–100 opacity percentage.
Generator::getFormatter
Rust exposes the format and the renderer can use it with any encoded matrix. It does not expose a Bacon-compatible mutable backend.
Generator::email and Email
Recipients must be ASCII mailboxes with a dotted domain. Reserved characters in the address are percent-encoded instead of being copied into the URI.
Generator::geo and Geo
The helper rejects coordinates outside the finite geographic range and emits decimal notation where PHP may emit scientific notation.
Generator::SMS and SMS
The SMS body is percent-encoded after a question mark in the URI, so special characters remain in the body.
Generator::wiFi and WiFi
Wi-Fi values escape field delimiters, hidden flags are spelled true or false, and the payload ends with a doubled semicolon.
Generator::BTC and BTC
Bitcoin amounts use decimal strings and an empty option set omits the question mark.
Generator::__call and DataTypeInterface
Typed Rust functions replace PHP magic method dispatch. Callers with custom payloads pass the text directly to the encoder.
QrCodeServiceProvider::register and Composer discovery
Laravel for Rust applications explicitly add the provider. PHP auto-discovers the provider through Composer.
QrCodeServiceProvider::provides
The Rust provider registers an injectable factory. It uses no PHP string binding or provider service list.
Bacon Shift-JIS dispatch and aliases
Both Shift-JIS spellings select the same policy. Eligible text uses Kanji mode and other text carries ECI 20 in byte mode, fixing Bacon 2.0.8 mode detection and missing ECI.
Unknown and nonexistent encoding labels
The typed parser rejects unavailable character sets up front, including ISO-8859-12. PHP can accept these names with numeric or alphanumeric data because it bypasses conversion for those modes.
UTF-8 input to the PHP writer
The text API takes valid UTF-8 by type. The separate binary API encodes opaque bytes without text conversion.

In practice

Generate a PNG

Encode a URL and leave a four-module quiet zone for scanning.

use laravel_rust_qrcode::{Format, Generator};

fn main() -> Result<(), laravel_rust_qrcode::Error> {
    let code = Generator::new()
        .format(Format::Png)
        .size(174)
        .margin(4)
        .generate("https://example.test/")?;
    println!("{} ({} bytes)", code.content_type(), code.as_bytes().len());
    Ok(())
}

Built on

  • Simple QrCode: The QR code builder this package ports: formats, styling, logos, payload helpers and Laravel integration, following version 4.2.0.

Crates: laravel-rust-qrcode, laravel-rust-qrcode-core · Upstream notices

Documentation