Weave 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 Laravel Package

bacon/bacon-qr-code

BaconQrCode is a pure-PHP QR code generator ported from ZXing's encoder. It renders QR codes to PNG, SVG, EPS or GD images with customizable size, margin, colors, gradients and eye styles, backed by a fast Reed-Solomon codec for quick output. Encoder only.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit

  • Pure-PHP, dependency-free (composer-only) QR encoder. No network calls, no external service, no database — it is a library, not an application, so it slots into Laravel's service-container model without ceremony.
  • The design is cleanly separated: an encoder (ZXing port + Phil Karn's Reed–Solomon codec, swapped in for PHP performance) feeding a Renderer strategy. ImageRenderer + a backend (Imagick, Svg, Eps) or the standalone GDLibRenderer are the only decisions a consumer makes. This is the natural seam for us to wrap.
  • No first-party Laravel integration exists — no service provider, facade, config file, or Blade directive. That is appropriate for a library of this scope but means we own the adapter layer: a QrCodeService bound as a singleton, a config/qr.php for defaults (size, margin, ECC level, foreground/background, disk), and a value object for style.
  • Encoder-only. If a future requirement involves scanning/decoding (e.g. validating a printed code, kiosk check-in), this package is out of scope and we would need a separate decoder or a JS-side library.

Integration feasibility

  • Install is a single composer require bacon/bacon-qr-code (v3.x requires PHP >= 8.1, which is comfortably inside Laravel 10/11/12 baselines). No publish step, no migrations, no bootstrapping.
  • Extension dependency is the only real gate, and it is per-backend:
    • SvgImageBackEnd → ext-xmlwriter (bundled by default in most PHP builds) — lowest risk.
    • GDLibRenderer → ext-gd (near-universal; enabled on Laravel Vapor by default).
    • ImagickImageBackEnd → ext-imagick (frequently absent; requires a Dockerfile/layer change on Vapor or container hosts).
  • Output is bytes/file/stream, so it composes trivially with Laravel primitives: Storage::disk()->put(), response()->streamDownload(), queued jobs, and mail attachments.

Technical risk

  1. Imagick rendering artifacts (documented, unresolved). Isolated white pixels can appear inside filled modules due to an ImageMagick GetFillAlpha rasterizer bug. The maintainers explicitly state it cannot be worked around in-library and recommend SVG or GD instead. This is a correctness risk for any code that must scan reliably at small physical sizes — treat it as a do-not-use backend unless an artifact workaround is proven on our target ImageMagick version.
  2. GD renderer is functionally reduced — no gradients, no curved module shapes, always square. Fine for utility output, not for branded/marketing codes.
  3. Backend lock-in by style requirements. Choosing Imagick for gradient/rounded-eye aesthetics buys us the artifact bug; choosing SVG avoids artifacts but needs xmlwriter and gives us a vector asset we must rasterize downstream if a PNG is demanded.
  4. Release metadata quality. The provided signals (Dependents: 0, overall score 3.3) look like an indexing artifact rather than reality — this package is a well-known engine behind higher-level QR wrappers. Validate before treating the score as a proxy for adoption; a 3.3 with a complete changelog, CI badge, codecov, and a 3.1.1 patch release does not square with "0 dependents."
  5. Major-version break precedent. 3.0.0 dropped PHP < 8.1 and reworked the GD renderer introduction; 2.0.0 broke the renderer API. Expect a 4.0 to arrive at some point with modest but real migration cost. Pin with a caret constraint and read changelogs on bump.
  6. Historical locale-sensitivity class of bugs (sprintf('%.3F') in SVG transforms, issue #100) — resolved, but indicative that float formatting under non-C locales has historically been a source of subtle breakage in this codebase. Worth a regression test on our side if we run de_DE/fr_FR locales.

Key questions

  • What is the actual rendering context: on-screen <img>, printed label, email, or downloadable asset? This single answer selects the backend and kills half the risk list.
  • Is ext-imagick present in all target environments (local, CI, staging, production, any queue workers)? If not, is it worth adding for aesthetics alone?
  • Do we need gradient/rounded-module branding, or is a square black-on-white code acceptable?
  • What is the expected code volume — per-request generation, or per-order asset creation with caching?
  • Are there compliance constraints on the encoded payload (signed URLs, PII in a scannable code)?

Integration Approach

Stack fit

  • Composer-native, PSR-4, zero framework coupling — the ideal shape for a Laravel library. It will not collide with Laravel's container, config caching, or Octane's long-lived workers (the library is stateless; renderers are cheap to construct per call, and even if held as singletons there is no mutable shared state across requests).
  • Recommended wrapper shape:
    • config/qr.php — default disk, size, margin, ECC level, backend, colors.
    • App\Support\Qr\QrCodeGenerator — builds RendererStyle + backend from config, exposes svg(string $payload): string, png(string $payload): string, store(string $payload, string $path, string $disk): void.
    • A QrCode value object on models (->qrSvg()) for ergonomics.
  • Do not reach for a facade-heavy wrapper package. The surface is three methods; a hand-rolled adapter is cheaper to own than a third-party Laravel bridge and avoids a second dependency with its own release cadence.

Migration path

  • From simplesoftwareio/simple-qrcode: that package is a thin convenience layer whose v4 line delegates to this library. Dropping to bacon/bacon-qr-code directly removes an intermediary, gains explicit control over RendererStyle, and gets us on the actively maintained 3.x line — at the cost of rewriting call sites (QrCode::size(300)->generate(...) → our adapter). Contained change if call sites are few.
  • From endroid/qr-code: verify its current encoder dependency chain before assuming equivalence; the migration is API-shaped rather than engine-shaped and should be scoped as a rewrite of the QR service, not a version bump.
  • Greenfield: start here. There is no cheaper option that is pure PHP, extension-light, and maintained.

Compatibility

  • PHP >= 8.1 (hard floor from 3.0.0). Confirm no service still runs 8.0 — this is the one genuine blocker if the estate is mixed.
  • Extension matrix must be encoded in infrastructure, not discovered in production: xmlwriter (probably fine), gd (probably fine), imagick (assume absent until proven).
  • No conflicts with Laravel, Symfony, or common imaging packages; the dependency graph is essentially empty, which is a supply-chain and upgrade-safety advantage.

Sequencing

  1. Spike (0.5 day). Render the same payload through SVG, GD, and Imagick at 200/400/1000 px; scan each with two phone scanners at print size. This settles the backend decision empirically and surfaces the Imagick artifact question before it becomes a bug ticket.
  2. Infrastructure decision. Either confirm ext-imagick end-to-end or commit to SVG/GD. Record the choice in the config default so it is not re-litigated.
  3. Adapter + config + tests. Unit tests asserting a fixed payload produces a byte-stable SVG (golden-file), plus a decode-and-compare smoke test if a decoder is available in CI.
  4. Storage & delivery. Decide the asset strategy (generate-on-demand vs. persist-to-disk vs. queue-precompute) and wire Storage/CDN.
  5. Theming, only if required. Gradients, eye styles, transparency — this is where Imagick tempts us back in; keep it behind a config flag so the default path stays artifact-free.
  6. Rollout behind a feature flag if replacing an existing generator, with a side-by-side comparison on a sample of live payloads.

Operational Impact

Maintenance

  • Actively maintained: CI badge, codecov, structured changelog, tagged releases through 3.1.1. Recent activity includes genuine bug fixes (QR version-4 EC block counts, Kanji encoding, EPS arc math, SVG gradient ID collisions) — a healthy signal that correctness issues get attention.
  • Bus-factor concern: this is a single-maintainer, community project with no corporate sponsor. Mitigation is that the codebase is small, stable, and vendored in composer.lock; the realistic failure mode is slow response to a new CVE or PHP version, not abandonment mid-quarter. Have a fallback noted (swap to a fork or pin the last good tag).
  • Upgrade cost is low: two breaking majors in ~5 years, each narrow in blast radius. Budget a half-day per major bump.
  • Our adapter layer is the durable asset; the library underneath is replaceable.

Support

  • Community-only: GitHub issues, no SLA, no commercial backing. Acceptable for a non-critical-path rendering utility; not acceptable as a dependency on a revenue-blocking checkout flow without our own tests around it.
  • Documentation is README-level. RendererStyle, Eye, and Color options are discoverable only by reading source or IDE completion. Expect one "how do I do rounded corners?" question per new engineer — solve it once with an internal README snippet, not per-incident.
  • Error messages are adequate but extension-missing failures surface as generic exceptions; wrap the adapter to translate these into actionable messages ("enable ext-imagick or switch qr.backend to svg").

Scaling

  • Encoding is CPU-bound and in-process — no I/O, no network, no lock contention. It is safe in queue workers, Octane, and FPM alike.
  • Cost per code is milliseconds, but at high volume it is pure waste to regenerate the same payload repeatedly. Cache rendered output keyed by hash(payload + style + backend). QR codes are deterministic; identical inputs must hit cache, and the cache key design is the main scale lever.
  • For high-traffic endpoints, precompute at write time (order placed → QR persisted to S3) rather than at read time. Serve from CDN.
  • Memory: large pixel dimensions (e.g., 2000px PNG) plus Imagick's internal buffers is the realistic memory ceiling; cap size in config and prefer SVG for anything above ~800px.
  • No per-request state, so horizontal scaling is a non-issue.

Failure modes

Mode Trigger Impact Mitigation
Missing PHP extension imagick/gd/xmlwriter absent in a new container or Vapor build Hard failure at render time Fail fast at boot (health check / config validation), document in Dockerfile, default to SVG
Imagick white-pixel artifacts Any Imagick raster render Codes that scan poorly at small print sizes or low margin Default to SVG/GD; test-scan output in CI
Payload too large Long URL with large query string, exceeds QR capacity for chosen ECC Encoder exception, broken UX Catch, validate length pre-encode, shorten URL/token instead of embedding raw data
Style feature unavailable Gradient/curves requested on GD backend Silent visual downgrade or exception Config guard: validate style vs. backend at boot
Output write failure Disk permissions, S3 credentials, disk full Missing assets downstream Queue + retry with backoff; surface to monitoring
Locale float formatting Non-C locale server with SVG/EPS transforms Malformed SVG/EPS geometry Regression test; set LC_NUMERIC=C or verify #100 fix holds on our version
Major-version surprise Caret bump picks up a 4.x with renderer API changes Broken adapter Pin ^3.1, upgrade deliberately with the golden-file tests

Ramp-up

  • Low for a Laravel engineer: one composer require, ~30 lines of adapter, done. The API is genuinely two classes deep.
  • Moderate for the styling surface: RendererStyle/Eye/Color/gradient configuration is undocumented and must be learned from src/. Budget a short internal write-up with copy-paste examples for the 3–4 styles we actually ship.
  • Non-trivial for a PHP novice only in the backend-selection reasoning (Imagick vs. GD vs. SVG trade-offs), which is why that decision should be made once, centrally, and encoded in config — not left to the implementing developer.
  • Overall: a low-risk, low-overhead adoption whose main residual risk is entirely avoidable if we (a) standardize on SVG or GD, (b) confirm PHP 8.1+, and (c) cache rendered output. The 3.3 score with 0 dependents should not be read literally — validate, but the artifact-level evidence (CI, coverage, changelog discipline, recent fixes) suggests a healthier project than the metadata implies.
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.
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route
mirvan/ippanel
ignibyte/aic-framework
glavweb/data-schema-bundle
glavweb/datagrid-bundle
tacticmedia/scim-server
uni-method/frame
neika-ai/sdk
adachsoft/php-code-style
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
adachsoft/api-version-bundle
cgv/localized-resource