bacon/bacon-qr-code library from v2 to v3, hardens the API with strict types, and drops legacy compatibility layers. Most applications need only a few targeted changes to upgrade cleanly.
Laravel 10 users: v3.x requires Laravel 12+ and PHP 8.2+. If you are on
Laravel 10 or PHP 8.1, stay on v1.x — it receives maintenance fixes and is the
supported path for those environments.
System Requirements
| Requirement | v1.x | v2.x | v3.x |
|---|---|---|---|
| PHP | 8.1+ | 8.2+ | 8.2+ |
| Laravel | 10+ | 11+ | 12+ |
| ext-gd | Required | Optional | Optional |
| ext-imagick | Optional | Optional | Optional (recommended) |
| Composer | 2.x | 2.x | 2.x |
Breaking Changes
Review every item below before running the upgrade command. Most changes affect only a small number of call sites.1. PHP and Laravel version requirements raised
1. PHP and Laravel version requirements raised
The minimum PHP version is now 8.2 and the minimum Laravel version is 12.0, matching the requirements of
bacon/bacon-qr-code v3.If your composer.json pins PHP or Laravel to an older constraint, update it first:2. Direct use of upstream library classes (advanced)
2. Direct use of upstream library classes (advanced)
This item only applies if your application imports classes from the
BaconQrCode library directly — for example, in a custom renderer or a low-level integration. If you only use the QrCode facade, the Blade component, or constructor injection, you are not affected and can skip this item.The underlying bacon/bacon-qr-code library reorganized several namespaces between its v2 and v3 releases. Notable changes include:| Old class | New class |
|---|---|
BaconQrCode\Writer | BaconQrCode\Writer\Writer |
BaconQrCode\Common\ErrorCorrectionLevel | Constants updated — see the bacon/bacon-qr-code releases |
3. color() and backgroundColor() now require integers
3. color() and backgroundColor() now require integers
Both methods now enforce integer arguments (0–255 for RGB, 0–100 for CMYK and alpha). Passing strings throws a type error.Search your codebase for calls to
->color( and ->backgroundColor( and confirm all arguments are integer literals or variables typed as int.4. simplesoftwareio/simple-qrcode compatibility dropped
4. simplesoftwareio/simple-qrcode compatibility dropped
v3.x removed the compatibility layer that allowed the
QrCode facade to act as a drop-in replacement for simplesoftwareio/simple-qrcode. If you migrated from that package and relied on any method signatures that do not exist in linkxtr/laravel-qrcode’s own API, you will need to update those call sites to use the new API.Check the API reference in the README for the current method signatures.5. Strict data validation — InvalidArgumentException on bad input
5. Strict data validation — InvalidArgumentException on bad input
In v1.x, passing malformed data to type methods (such as a bad phone number or an incomplete WiFi config) could silently generate a corrupted QR code. In v3.x, all data types validate their inputs strictly and throw
InvalidArgumentException on failure.Wrap any call that accepts dynamic user input in a try/catch:6. Config defaults changed in v2.4.x
6. Config defaults changed in v2.4.x
Starting in v2.4.0, the package ships with updated defaults to better reflect modern usage:
If your application relied on the previous defaults and you have not published the config file, you may notice changes in QR code output after upgrading. Publish the config and set these values explicitly to lock in your preferred defaults.
| Key | v1.x / pre-2.4 default | v2.4.x+ / v3.x+ default |
|---|---|---|
format | png | svg |
size | 200 | 400 |
error_correction | H | M |
Upgrade Steps
Update the package constraint
Run the following command in your project root:Composer will pull in the latest v3.x release along with
bacon/bacon-qr-code v3.Update color() and backgroundColor() calls
Find every call to A quick search command to locate these calls:
->color( and ->backgroundColor( in your application and confirm each argument is an integer:Publish and review the config file
If you have not already published the config, do so now:This creates
config/qrcode.php. Open it and explicitly set format, size, and error_correction to match what your application expects, so you are never affected by future default changes:Wrap dynamic inputs in try/catch
Identify every place where user-supplied data flows into a data-type method (
WiFi, Email, PhoneNumber, SMS, VCard, etc.) and add InvalidArgumentException handling: