# Migrating from PHP (laravel-rust-qrcode)

> Find the Rust equivalents of Simple QrCode methods and see where QR encoding, rendering, and payloads behave differently.

- Package: laravel-rust-qrcode (Laravel for Rust, alpha), crates: `laravel-rust-qrcode`, `laravel-rust-qrcode-core`
- Maintenance: active; Latest release: 0.1.0 (2026-12-04); Framework: laravel-rust 0.2.x; MSRV: Rust 1.99 or later; Licence: MIT
- Links: [Repository](https://github.com/bowerbird-si/laravel-rust-qrcode), [crates.io](https://crates.io/crates/laravel-rust-qrcode/0.1.0), [docs.rs](https://docs.rs/laravel-rust-qrcode/0.1.0), [Changelog](https://oss.bowerbird.si/qrcode/docs/changelog/), [Contributing](https://github.com/bowerbird-si/laravel-rust-qrcode/blob/0d4061426c0e70f1d1e0fac79c65fe7f046a3dab/CONTRIBUTING.md), [Security policy](https://github.com/bowerbird-si/laravel-rust-qrcode/blob/0d4061426c0e70f1d1e0fac79c65fe7f046a3dab/SECURITY.md)
- Based on: [Simple QrCode](https://github.com/SimpleSoftwareIO/simple-qrcode): The QR code builder this package ports: formats, styling, logos, payload helpers and Laravel integration, following version 4.2.0.
- PHP parity: core (13 covered, 19 diverged, 18 planned of 50 abilities; 83 fixtures; follows simplesoftwareio/simple-qrcode 4.2.0; verified 2026-12-04)
- Community package, not affiliated with Laravel.
- HTML version: https://oss.bowerbird.si/qrcode/docs/migrating-from-php/
- Source: https://github.com/bowerbird-si/laravel-rust-qrcode/blob/0d4061426c0e70f1d1e0fac79c65fe7f046a3dab/docs/migrating-from-php.md

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.
