Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Bacon Qr Code

Bacon Qr Code Laravel Package

bacon/bacon-qr-code

PHP QR code generator (ZXing encoder port) with multiple renderers/back ends: Imagick, SVG, EPS, and a separate GDLib renderer. Generate QR codes to files or output with customizable size/style via Renderer and Writer APIs.

View on GitHub
Deep Wiki
Context7

bacon/bacon-qr-code is a fast, reliable QR code generator for PHP, ported from the QR encoding portion of ZXing. It focuses on encoding (not decoding) and swaps ZXing’s slower Reed–Solomon implementation for Phil Karn’s, making it well-suited for production QR generation.

Render QR codes to common formats using flexible renderers/backends, including high-quality raster output via Imagick and vector output via SVG or EPS.

  • ZXing-based QR encoder with PHP-friendly performance
  • Multiple render backends: Imagick, SVG (XMLWriter), EPS
  • Simple API via Writer to output files or strings
  • Separate GDLibRenderer option for environments without Imagick
  • Configurable sizing/styles via RendererStyle
Frequently asked questions about Bacon Qr Code
How do I install bacon/bacon-qr-code in a Laravel project?
Use Composer: `composer require bacon/bacon-qr-code`. For Laravel 10+, ensure PHP 8.1+ is installed. If using older Laravel versions, downgrade to v2.x (PHP 7.1+). Verify `ext-imagick` or `ext-xmlwriter` is enabled for Imagick/SVG support.
Which Laravel versions does bacon/bacon-qr-code support?
The package officially supports Laravel 10+ (PHP 8.1+). For Laravel 9.x or older, use v2.x of the package, but test thoroughly as it may introduce compatibility risks. Always check the [release notes](https://github.com/Bacon/BaconQrCode/releases) for updates.
Can I generate QR codes asynchronously in Laravel?
Yes. Use Laravel Queues to offload QR generation. Create a job (e.g., `GenerateQrCodeJob`) that uses the `Writer` class, then dispatch it via `GenerateQrCodeJob::dispatch($text, $path)`. Ideal for batch processing or high-traffic applications.
What are the differences between Imagick, SVG, and GDLib renderers?
Imagick produces high-quality raster images but may have white pixel artifacts. SVG generates vector output (scalable, lightweight) but requires `ext-xmlwriter`. GDLib is a fallback for environments without Imagick/SVG but lacks gradients and curves, producing square-only QRs. Choose based on quality needs and server dependencies.
How do I store generated QR codes in Laravel?
Use Laravel Storage: save files to `storage/app/qrcodes/` or `public/qrcodes/` via `Storage::put()`. For databases, store as binary (LONGTEXT) or file paths. For dynamic QRs, encode as base64 strings or serve via temporary storage endpoints. Avoid bloating storage with large batches.
Will bacon/bacon-qr-code work with Unicode/Kanji characters?
Yes, the package supports Unicode and Kanji. Test edge cases (e.g., CJK characters) in a staging environment to ensure proper rendering. If issues arise, verify your renderer backend (Imagick/SVG) handles the character set correctly.
How can I integrate bacon/bacon-qr-code into Laravel’s service container?
Register it as a service provider. Bind the `Writer` to the container in `AppServiceProvider` or a dedicated provider, then inject it into controllers/services. Example: `$this->app->singleton('qr-code', fn() => new Writer(new ImageRenderer(new RendererStyle(400), new ImagickImageBackEnd())));`.
What’s the best way to handle QR code generation for large-scale applications?
Combine async queues, caching, and optimized storage. Use Laravel Queues for batch processing, cache generated QRs (e.g., Redis), and store outputs as files or base64 strings. Benchmark Imagick vs. SVG for performance—SVG may be faster for web delivery.
Are there alternatives to bacon/bacon-qr-code for Laravel?
Yes. For simpler needs, consider `endroid/qr-code` (easy API, GD/SVG support) or `michelf/php-qrcode` (lightweight but less performant). For advanced use cases, `bacon/bacon-qr-code` offers better performance (Phil Karn’s Reed-Solomon) and renderer flexibility. Evaluate based on your project’s PHP version and dependency constraints.
How do I customize QR code size, colors, or margins?
Use `RendererStyle` to configure size, margins, and colors. Example: `new RendererStyle(400, RendererStyle::ECC_LOW, 'black', 'white')` sets a 400px QR with low error correction, black foreground, and white background. Pass this to your renderer (e.g., `ImageRenderer` or `GDLibRenderer`).
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport