Laravel for Go Alpha
laravel-go-qrcode
Styled QR codes for Go and Laravel for Go.
Render QR codes as SVG, PNG or EPS. Set module and eye shapes, colors and gradients, and add logos to PNG output.
Read the docs Source on GitHub
go get github.com/bowerbird-si/laravel-go-qrcode@v0.1.0- Latest release
- 0.1.0, 2026-12-04
- Maintenance
- Active
- Framework
- go.laravel.com v0.2.0 or later
- Go
- Go 1.27 or later
- Licence
- MIT
PHP conformance fixtures
Tests compare behavior with fixtures from
simplesoftwareio/simple-qrcode4.2.0. The parity matrix records tested abilities and deliberate differences.Typed payload helpers
Build payloads for WiFi networks, email, SMS, geographic coordinates, phone numbers and Bitcoin payments. Each helper validates its input.
Laravel for Go adapter
Register
laravelqrto use a shared generator, view helpers and image responses with the matching content type.
PHP parity
Follows simplesoftwareio/simple-qrcode 4.2.0 (commit 916db7948ca6). Last verified .
- Parity level
- Full
- Abilities
- 50
- Covered
- 23
- Diverged
- 27
- Planned
- 0
- PHP fixtures
- 74
Coverage by ability
-
generate· Covered · Core · 2 testsGenerator::generate and Writer defaults -
generate.file· Covered · 2 testsGenerator::generate with filename -
format.svg· Covered · Core · 3 testsGenerator::format('svg') -
format.png· Covered · Core · 3 testsGenerator::format('png') -
format.eps· Covered · 3 testsGenerator::format('eps') -
format.invalid· Covered · 2 testsGenerator::format validation -
size· Covered · Core · 3 testsGenerator::size -
margin· Covered · Core · 2 testsGenerator::margin -
correction· Covered · Core · 1 testGenerator::errorCorrection -
encoding· Covered · 1 testGenerator::encoding -
matrix.auto· Diverged · CoreWriter automatic encoding policy -
color.foreground· Covered · 2 testsGenerator::color -
color.background· Covered · 3 testsGenerator::backgroundColor -
color.create· DivergedGenerator::createColor -
gradient· Covered · 3 testsGenerator::gradient -
style· Covered · 3 testsGenerator::style -
eye· Covered · 3 testsGenerator::eye -
eye.color· DivergedGenerator::eyeColor -
merge.file· DivergedGenerator::merge -
merge.bytes· Covered · 1 testGenerator::mergeString -
merge.format· DivergedGenerator PNG-only merge -
image.decode· Covered · 1 testImage::__construct -
image.width· Covered · 1 testImage::getWidth -
image.height· Covered · 1 testImage::getHeight -
image.get· DivergedImage::getImageResource -
image.set· DivergedImage::setImageResource -
image.merge.new· Covered · 1 testImageMerge::__construct -
image.merge· DivergedImageMerge::merge -
renderer.writer· DivergedGenerator::getWriter -
renderer.get· DivergedGenerator::getRenderer -
renderer.style· DivergedGenerator::getRendererStyle -
renderer.format· DivergedGenerator::getFormatter -
renderer.module· DivergedGenerator::getModule -
renderer.eye· DivergedGenerator::getEye -
renderer.fill· DivergedGenerator::getFill -
helper.email· DivergedGenerator::email and Email -
helper.geo· DivergedGenerator::geo and Geo -
helper.phone· DivergedGenerator::phoneNumber and PhoneNumber -
helper.sms· DivergedGenerator::SMS and SMS -
helper.wifi· DivergedGenerator::wiFi and WiFi -
helper.btc· DivergedGenerator::BTC and BTC -
helper.dispatch· DivergedGenerator::__call and DataTypeInterface -
laravel.provider.register· Covered · 1 testQrCodeServiceProvider::register and Composer discovery -
laravel.provider.provides· DivergedQrCodeServiceProvider::provides -
laravel.facade· DivergedQrCode facade alias and cache clear -
laravel.html· Diverged · CoreGenerator::generate HtmlString and documented Blade use -
laravel.image· Covered · 1 testDocumented email embed and base64 PNG -
encoding.shift-jis· DivergedBacon Shift-JIS dispatch and aliases -
encoding.invalid· DivergedUnknown and nonexistent encoding labels -
generate.text· Covered · 2 testsUTF-8 input to the PHP writer
Differences from PHP (27)
Writer automatic encoding policy- The encoder uses its standard mask scoring and chooses the smallest fitting version. For example, 34 digits at level M fit version 1 in Go and use version 2 in PHP. Controlled matrices and automatic decoded payloads are tested.
Generator::createColor- Callers construct native color.NRGBA values with 0 to 255 opacity. PHP createColor returns a Bacon color with a 0 to 100 alpha scale.
Generator::eyeColor- Go takes outer and inner colors in physical order. PHP names the outer ring color inner and defaults the actual center to black when the second color is omitted.
Generator::merge- Callers read their own local file and pass bytes or an image. PHP file paths may resolve relative to the application or be read through URL wrappers.
Generator PNG-only merge- Adding a logo to a non-PNG format returns ErrInvalidOption. PHP silently omits the logo.
Image::getImageResource- Go accepts image.Image supplied by the caller in place of exposing a GD resource.
Image::setImageResource- A logo is snapshotted for immutable generator reuse. Applications can create a new option with an updated image.
ImageMerge::merge- Go fits the centered logo within the symbol and uses its exact aspect ratio. PHP rounds that ratio before calculating the output height.
Generator::getWriter- Go exposes io.Writer rendering and read-only matrices for custom consumers in place of Bacon's Writer object.
Generator::getRenderer- Go renders with the generator's format methods. Encode exposes a read-only matrix for custom rendering without a Bacon renderer object.
Generator::getRendererStyle- Go uses typed generator options and does not expose a Bacon RendererStyle object.
Generator::getFormatter- Go selects a typed format and returns the rendered bytes or sends them to a writer. It does not expose a Bacon image backend.
Generator::getModule- Go configures module geometry with a typed option and provides the raw matrix for custom consumers.
Generator::getEye- Go configures the finder shape with a typed option without returning a Bacon EyeInterface.
Generator::getFill- Go configures native colors and gradients through options without returning a Bacon Fill object.
Generator::email and Email- Go escapes mail query spaces as percent-20 and normalizes body line breaks to CRLF. PHP uses form encoding with plus for spaces.
Generator::geo and Geo- Go validates latitude and longitude and uses plain decimals even for tiny coordinates. PHP may format them using scientific notation.
Generator::phoneNumber and PhoneNumber- Go validates telephone numbers and converts spaces to hyphens as URI visual separators. PHP preserves spaces and otherwise returns the number verbatim.
Generator::SMS and SMS- Go uses an RFC 5724 body query with percent escaping. PHP appends an unescaped &body= suffix.
Generator::wiFi and WiFi- Go escapes WiFi delimiters and emits true or false for an explicit hidden setting. PHP writes raw fields and coerces boolean values to 1 or an empty string.
Generator::BTC and BTC- Go uses an exact decimal amount, percent-escapes URI parameters, and omits the question mark for an absent query.
Generator::__call and DataTypeInterface- Go exposes explicitly typed payload builders and composes their output with Generate. PHP dispatches helper method names dynamically to classes.
QrCodeServiceProvider::provides- The Go package registers a typed service and view functions up front. Laravel for Go uses explicit package installation without PHP deferred-provider metadata.
QrCode facade alias and cache clear- Applications explicitly install the Go package and resolve its immutable generator from the current application context. Composer aliases and static facade dispatch are PHP-specific.
Generator::generate HtmlString and documented Blade use- Only the inline SVG template helper returns trusted HTML. PNG and EPS remain binary response bodies without wrapping in an HTML string.
Bacon Shift-JIS dispatch and aliases- Go normalizes Shift-JIS aliases, writes ECI 20 in byte mode, and encodes valid Kanji without the pinned PHP TypeError.
Unknown and nonexistent encoding labels- An unknown encoding label is rejected when configuring the generator, including cases where numeric data could otherwise skip transcoding.
In practice
Render SVG and PNG
Reuse the generator to render the same text as SVG or a PNG data URI.
g, err := qrcode.New(qrcode.Size(200), qrcode.Margin(4))
if err != nil {
log.Fatal(err)
}
svg, err := g.SVG("https://example.com")
if err != nil {
log.Fatal(err)
}
src, err := g.DataURI("https://example.com", qrcode.PNGFormat)
if err != nil {
log.Fatal(err)
}Show a QR code in a Laravel view
Register the adapter to inline SVG with qrcode or get a PNG data URI with qrcodeSrc.
{{ qrcode .TicketURL }}
<img src="{{ qrcodeSrc .TicketURL }}" alt="Ticket QR code">Built on
- Simple QrCode: The QR code builder this package ports: formats, styling, logos, payload helpers and Laravel integration, following version 4.2.0.
- go-qr: QR encoding.
- gozxing: Scans the generated codes in the tests.
Go modules: github.com/bowerbird-si/laravel-go-qrcode
· Upstream notices
Documentation
- OverviewGenerate QR codes as SVG, PNG or EPS from Go, and show them in Laravel for Go views and responses. A port of simplesoftwareio/simple-qrcode.
- Getting startedInstall the module, create a generator and render your first QR code as SVG, PNG or EPS.
- Options and stylesPass options to qrcode.New, Generator.With, laravelqr.New, laravelqr.Response or the view functions. They apply in order, so a later option wins.
- PayloadsA QR code holds text. Phones act on some formats: they open an email draft, dial a number or join a WiFi network. Each payload type builds that text; pass the…
- Laravel for GoThe laravelqr subpackage installs a shared generator in your app, adds two view functions and returns QR images from routes.
- Migrating from PHPEach simplesoftwareio/simple-qrcode call and its Go equivalent. In PHP you chain settings on the QrCode facade; in Go you pass options to qrcode.New (or…
- ChangelogWhat changed in each release of laravel-go-qrcode: additions, changes and fixes.