nowo-tech / qr-code-bundle
Symfony bundle to generate PNG QR codes as data URIs with optional URL safety policy.
Package info
github.com/nowo-tech/QrCodeBundle
Language:Shell
Type:symfony-bundle
pkg:composer/nowo-tech/qr-code-bundle
Fund package maintenance!
Requires
- php: >=8.1 <8.6
- endroid/qr-code: ^6.0
- symfony/config: ^7.0 || ^8.0
- symfony/dependency-injection: ^7.0 || ^8.0
- symfony/http-kernel: ^7.0 || ^8.0
- symfony/twig-bundle: ^7.0 || ^8.0
- symfony/ux-twig-component: ^2.20 || ^3.0
- twig/twig: ^3.8 || ^4.0
Requires (Dev)
- doctrine/doctrine-bundle: ^2.12 || ^3.0
- doctrine/orm: ^2.19 || ^3.0
- friendsofphp/php-cs-fixer: ^3.0
- nowo-tech/phpstan-frankenphp: ^1.0
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-symfony: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
- symfony/form: ^7.0 || ^8.0
- symfony/framework-bundle: ^7.0 || ^8.0
- symfony/security-core: ^7.0 || ^8.0
- symfony/validator: ^7.0 || ^8.0
- symfony/yaml: ^7.0 || ^8.0
Suggests
- ext-gd: Required by endroid/qr-code for PNG rendering
- doctrine/doctrine-bundle: Required when nowo_qr_code.use_database_config is true
- doctrine/orm: Required when nowo_qr_code.use_database_config is true (DB profile overrides + admin CRUD)
- symfony/form: Required for the optional /admin/qr-code-profiles CRUD
- symfony/security-bundle: Recommended to protect admin CRUD via security.access_roles
- symfony/ux-toolkit: Optional design-system toolkit (PHP 8.4+); NowoQrCode follows Toolkit @prop documentation conventions and works alongside Shadcn kit components
- symfony/validator: Recommended for admin form constraints
README
⭐ Found this useful? Install from Packagist · Give it a star on GitHub so more developers can find it.
Symfony bundle to generate PNG QR codes as data URIs, with optional URL validation (http/https only) and host allowlisting.
Used by WalletQrBundle for wallet save-link QRs, and usable standalone in any Symfony app.
This bundle is FrankenPHP worker mode friendly.
Features
- ✅ PNG QR codes as data URIs (
QrCodeService/QrCodeDataUriRenderer) - ✅ Named profiles (
default_profile+profiles) for size, ECC, and allowlists - ✅ Optional Doctrine storage: DB profiles override YAML by name (
use_database_config) - ✅ Admin CRUD at
/admin/qr-code-profiles(when DB storage is enabled) - ✅ URL safety policy (
QrUrlPolicy; blocksjavascript:,data:, etc.) - ✅ Optional host/URL allowlist (exact host or subdomain; path substrings;
#regex) - ✅ Typed
QrErrorCorrectionenum (low|medium|quartile|high) - ✅ Twig helpers
qr_code_data_uriandqr_code_for_url(optional profile argument) - ✅ Twig UX component
<twig:NowoQrCode>(symfony/ux-twig-component) - ✅ Compatible with Symfony UX Toolkit (optional host dependency, PHP 8.4+)
- ✅ Symfony configuration under
nowo_qr_code
Quick start
composer require nowo-tech/qr-code-bundle
Requires PHP gd (or another writer backend supported by endroid/qr-code).
# config/packages/nowo_qr_code.yaml nowo_qr_code: default_profile: default profiles: default: size: 300 margin: 10 error_correction: high url_allowlist: [] compact: size: 128 margin: 2 error_correction: medium url_allowlist: - example.com
use Nowo\QrCodeBundle\Service\QrCodeService; $dataUri = $qrCodeService->createDataUri('https://example.com'); $safeUri = $qrCodeService->createDataUriForUrl('https://example.com/path', 'compact');
<img src="{{ qr_code_data_uri('Hello') }}" alt="QR"> <img src="{{ qr_code_for_url(downloadUrl, 'compact') }}" alt="QR"> <twig:NowoQrCode content="Hello" class="qr" /> <twig:NowoQrCode url="{{ downloadUrl }}" profile="compact" />
Related
- WalletQrBundle — Google Wallet / Apple Wallet save links + QR (depends on this bundle)
Documentation
- Installation
- Configuration
- Usage
- Contributing
- Code of Conduct
- Changelog
- Upgrading
- Release
- Security
- Engram
- Spec-driven development
- GitHub Spec Kit
Additional documentation
Tests and coverage
| Stack | Coverage | How to run |
|---|---|---|
| PHP | 100% lines (src/) |
make test-coverage / composer test-coverage |
| TypeScript / JavaScript | N/A (no frontend assets) | — |
| Python | N/A | — |
CI enforces PHP coverage at 100% (Clover elements / line gate via .scripts/coverage-check-100.php).
License
MIT © Nowo.tech
