- How do I install 2amigos/qrcode-library in a Laravel app?
- Install it with composer require 2amigos/qrcode-library. The package ships a Laravel bridge under Da\QrCode\Bridge\Laravel, so register the service provider and alias exactly as the README describes for your version. Before generating your first code, confirm ext-gd is enabled in your PHP image, since the default backend depends on it.
- Which PHP and Laravel versions does 2amigos/qrcode-library support?
- Version 4.x requires PHP 8.3, 8.4 or 8.5, so any app or CI image still on 8.1 or 8.2 must be upgraded first. The release notes document the PHP floor but are silent on Laravel and Illuminate ranges, so check the package composer.json before planning the upgrade. Treat the PHP bump as a program-level cost rather than a single ticket.
- Does 2amigos/qrcode-library require ImageMagick, or does GD work?
- Version 4 defaults to a pure-GD backend (GdImageBackEnd), so PNG and JPG output only needs ext-gd and no native ImageMagick binary. That removes the most common deployment blocker for this class of package and turns a custom base image into a standard PHP extension requirement. ImageMagick is still supported, but it is now opt-in through the writer constructor.
- What output formats can 2amigos/qrcode-library generate?
- Depending on the backend and writer you pick, the library produces raster formats such as PNG and JPG and vector formats such as SVG, with EPS available through the ImageMagick path. The GD backend covers PNG and JPG without any native dependency, while imagick-only features require deliberately opting into that writer. Pin down which formats your app actually renders before choosing a backend.
- How do I customize QR code size, colors, margin and error correction?
- You configure size, foreground and background colors, margin and error correction level through the QrCode object before rendering. In 4.x the gradient type is a GradientType object rather than a scalar, so avoid persisting it or comparing it as a string. If you cache rendered output, key it on the resolved configuration rather than the object itself.
- How do I display a QR code in a Blade view or return it as a download?
- Render the code to a string or stream and return it from your controller with the correct content type, or embed it in Blade as a data URI. The Laravel bridge is a thin adapter at the edge of the app, so keep the render call inside a small controller or service rather than spreading it through views. That keeps swapping the library later cheap.
- How do I save a generated QR code to Laravel storage?
- Write the rendered code to a path or capture it as a string, then pass the result to Laravel's Storage facade, for example Storage::disk('public')->put(...). Keeping generation in one injectable service class means the QR library stays an edge concern instead of leaking into your domain code. It also makes the eventual framework or package migration a one-file change.
- What are the breaking changes in 2amigos/qrcode-library 4.0?
- Namespaces moved under Da\QrCode\Bridge\<Framework>\ with redundant Laravel class-name prefixes dropped, so old FQCNs in use statements, config files and container bindings break at runtime rather than at install time. getGradientType() now returns a GradientType object, which can silently break string comparisons, array and cache keys, and JSON serialisation, though StyleManager::getGradientTye() keeps a deprecated alias. Dependency floors moved to bacon/bacon-qr-code ^3 and khanamiryan/qrcode-detector-decoder ^2, and default rendering output changed, so pixel-snapshot tests need re-baselining as an intentional change.
- How do I add a logo or text label to a QR code?
- Text and label rendering relies on FreeType support in your GD build, so compile or install GD with --with-freetype. Without it, label rendering and vCard photo compositing fail at render time rather than at boot, which is easy to miss in CI. Do one render inside your actual container image before depending on it in production.
- Is 2amigos/qrcode-library maintained, and what are the alternatives?
- The project has adopted a modern toolchain with php-cs-fixer v3, PHPStan and an 8.3/8.4/8.5 CI matrix, which is a positive sustainability signal, but it is still effectively a single-maintainer package and worth recording as a supply-chain risk. Alternatives include endroid/qr-code and simple-qrcode. For a Laravel codebase the decision usually comes down to backend requirements (GD versus imagick), the output formats you need, and how thin the framework adapter is.