Find the Rust equivalents of Simple QrCode methods and see where QR encoding, rendering, and payloads behave differently.
| PHP | Laravel for Rust |
|---|---|
| Composer package discovery | Register QrCodeServiceProvider with with_providers. |
QrCode facade | Use Generator::new() or inject QrCodeFactory and call builder(). |
generate($text) | Use .generate(text)? and read the format-aware image. |
generate($text, $filename) | Use .write_to(text, path)?. |
format('png') | Use .format(Format::Png) or parse the label at runtime. |
size(250), margin(4) | Use .size(250).margin(4). |
errorCorrection('H') | Use .error_correction(ErrorCorrection::High). |
encoding('UTF-8') | Use .encoding(Encoding::Utf8) or parse the label. |
color(255, 0, 0) | Use .color(Color::rgb(255, 0, 0)). |
backgroundColor(255, 255, 255, 25) | Use .background_color(Color::rgba(255, 255, 255, 64)). |
| Raw SVG in Blade | Use {{ qrcode(text, 100) }} in MiniJinja. |
| Base64 PNG source in Blade | Use {{ qrcode_png(text) }} in MiniJinja or .png_data_uri(text)? in Rust. |
email($to, $subject, $body) | Pass the result of payload::email(Some(to), Some(subject), Some(body))? to generate. |
geo($latitude, $longitude) | Pass the result of payload::geo(latitude, longitude)? to generate. |
phoneNumber($number) | Use payload::phone_number(number). |
SMS($number, $message) | Use payload::sms(Some(number), Some(message)). |
wiFi($options) | Use payload::Wifi::new(ssid).security(WifiSecurity::Wpa, Some(password)).payload(). |
BTC($address, $amount, $options) | Set a decimal string in a default payload::BitcoinOptions and call payload::btc(address, options)?. |
Custom DataTypeInterface | Pass the payload string to generate. |
getWriter(), getRenderer(), getFormatter() | Configure typed Encoder and Renderer values and use with_encoder and with_renderer. |
style(), eye(), eyeColor(), gradient(), getModule(), getEye(), getRendererStyle(), getFill() | Planned. |
merge(), mergeString(), standalone Image and ImageMerge | Planned. |
Payload and image differences
- Automatic QR encoding can choose a smaller fitting version or a different valid mask. Controlled encoding reproduces PHP modules when the encoded bytes, data mode, ECI, and error-correction level match.
- The generator accepts ISO-8859-1 by default. Templates use UTF-8. Both Shift-JIS spellings use Kanji mode for eligible text and ECI 20 in byte mode. Unsupported encoding labels fail during parsing. EUC-KR and Windows-1252 conversions can accept code points that PHP's iconv rejects.
- Size and margin are bounded. PNG needs at least one pixel per module. Colors take alpha as a byte and EPS composites partial alpha onto white.
- Email accepts ASCII mailboxes with a dotted domain and percent-encodes reserved characters in recipients. Geo coordinates must be finite and in range. SMS makes the body a percent-encoded query parameter. Wi-Fi escapes delimiter characters, uses explicit hidden flags, and ends with two semicolons. Bitcoin amounts use decimal strings and the helper omits an empty query. Validate untrusted SMS destinations or Bitcoin addresses before passing them to the helpers.
- Each builder uses independent options. Rendered binary output has bytes and a MIME type. Template functions handle inline SVG and PNG data URIs.