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 ported from ZXing (encoder only). Render to PNG via Imagick, or output SVG/EPS; includes a separate GDLib renderer. Simple Writer API to generate QR codes to files or strings.

View on GitHub
Deep Wiki
Context7

QR Code Generator for PHP

Frequently asked questions about Bacon Qr Code
How do I install BaconQrCode in a Laravel project?
Run `composer require bacon/bacon-qr-code` in your project root. Ensure PHP 8.1+ is used (Laravel 9/10). No additional Laravel-specific setup is required beyond Composer autoloading.
Which Laravel versions does BaconQrCode support?
The package works with Laravel 9+ (PHP 8.1+) and Laravel 10+ (PHP 8.2+). For Laravel 8 (PHP 8.0), use version 2.x of BaconQrCode, which supports PHP 7.1+.
Can I generate QR codes dynamically in a Laravel API response?
Yes. Use `Response::make($writer->writeString($text), 200, ['Content-Type' => 'image/png'])` in your controller. For SVG/EPS, adjust the Content-Type header accordingly.
What are the performance implications of using Imagick vs. GDLib?
Imagick offers higher quality but may introduce minor white pixel artifacts. GDLib is faster but lacks gradients/curves. Benchmark both for your use case—GDLib is ideal for bulk generation, while Imagick/SVG suits high-quality needs.
How do I handle missing PHP extensions (e.g., Imagick) in production?
Fallback to `SvgImageBackEnd` or `GDLibRenderer` in your code. For critical deployments, queue QR generation as a job (e.g., `ShouldQueue`) to handle extension unavailability gracefully.
Can I customize QR code colors or add logos?
BaconQrCode supports basic styling via `RendererStyle` (e.g., size, margins). For advanced customization like logos or gradients, use SVG output or combine with Imagick post-processing.
Is BaconQrCode suitable for high-volume QR generation (e.g., invoices)?
Yes, but test performance first. For bulk operations, queue jobs or cache generated QR codes. The package’s Reed-Solomon encoding is optimized but may introduce latency—compare with alternatives like `endroid/qr-code` if needed.
How do I integrate BaconQrCode with Laravel’s service container?
Bind the `Writer` class to an interface (e.g., `QrCodeGenerator`) in `AppServiceProvider`. Example: `app()->bind(QrCodeGenerator::class, fn() => new Writer(new ImageRenderer(...)));`. This enables mocking for tests.
Are there alternatives to BaconQrCode for Laravel?
Yes. Consider `endroid/qr-code` (more features, slower) or `chillerlan/php-qrcode` (lightweight, GD-only). BaconQrCode stands out for its ZXing-based encoding and multi-backend support (Imagick/SVG/GD).
How do I test QR code generation in Laravel?
Mock the `Writer` interface in unit tests. For integration tests, verify output files or responses. Use `Storage::fake()` to test file-based generation. Example: `assertFileExists(storage_path('app/qrcodes/test.png'));`
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.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata