一个强大的 QR 码管理库,适用于 PHP
HeroQR is a PHP library for generating and customizing QR codes with full control over styling and multi-format output, while remaining ISO/IEC 18004 compliant.
Customization
Geometric Styling
Data Support
Validation
Export Formats
Reliability
Use Composer to install the library. Also make sure you have enabled and configured the GD extension if you want to generate images.
composer require amirezaeb/heroqruse HeroQR\Core\QRCodeGenerator;
$qrCode = (new QRCodeGenerator())
->setData('https://test.org')
->generate();
$qrCode->saveTo('qrcode'); The saveTo() method automatically resolves and appends the appropriate file extension based on the selected output format.
Advanced configuration options for full control over QR code generation and validation.
Granular Customization: Fine-tune colors, size, logos, and typography.
Smart Validation: Use the optional DataType to automatically validate inputs like URL, Email, Phone, Wi-Fi, and more.
…HeroQR supports custom styling for QR modules, corner markers, and alignment cursors.
This feature is available for PNG and SVG output formats.
S1 to S4M1 to M6C1 to C6use HeroQR\Core\QRCodeGenerator;
$qrCode = (new QRCodeGenerator())
->setData('https://github.com/amirezaeb/heroqr')
->setSize(800)
->setBackgroundColor(0, 0, 0, 0)
->setColor(0, 100, 200)
->generate('svg',[
'Shape' => 'S2',
'Marker' => 'M2',
'Cursor' => 'C2'
]);
$qrCode->saveTo('custom-qr');Examples
| Combination | Shape (Body) | Marker (Corner) | Cursor (Inner) | Preview |
|---|---|---|---|---|
| S1-M1-C1 | Square (Default) | Square (Default) | Square (Default) | View |
| S2-M2-C2 | Circle (Custom) | Circle (Custom) | Circle (Custom) | View |
| S3-M3-C3 | Star (Custom) | D-Drop-O (Custom) | D-Drop-O (Custom) | View |
| S4-M4-C4 | Diamond (Custom) | D-Drop-I (Custom) | D-Drop-I (Custom) | View |
| S4-M5-C5 | Diamond (Custom) | D-Drop-IO (Custom) | D-Drop-IO (Custom) | View |
| S4-M6-C6 | Diamond (Custom) | Square-O (Custom) | Square-O (Custom) | View |
HeroQR supports multiple output formats for flexible usage in web, CLI, and custom rendering environments.
use HeroQR\Core\QRCodeGenerator;
$qrCode = (new QRCodeGenerator())
->setData('https://test.org')
->generate();
# Raw binary string
$string = $qrCode->getString();
# Matrix object
$matrix = $qrCode->getMatrix();
# 2D array
$matrixArray = $qrCode->getMatrixAsArray();
# Base64 Data URI
$dataUri = $qrCode->getDataUri();
# Save to file
$qrCode->saveTo('qr_code_output');HeroQR follows a modular architecture designed for scalability and maintainability.
src/
├── Contracts/
├── Core/
├── DataTypes/
├── Managers/
├── Customs/
└── Tests/If HeroQR is useful in your projects, you can support its development by:
GRAM (TON)
UQBejif4zPS57KWzz9VcqNHgRqLiOs72--xcoMyLkbnvyvn2USDT (TRC-20)
TEbQ2K3kWF1TjE4yRuqp6hTH8FRr7n7xGX
Organizations interested in sponsoring HeroQR or featuring their brand in the documentation may contact us via the Contact section.
Contributions are welcome.
Example:
git checkout -b feature/amazing-feature
git commit -m "feat: add support for custom frame colors"
git push origin feature/amazing-featurePlease provide a clear description of your changes and reference any related issues (e.g. Fixes #123).
HeroQR is open-sourced software licensed under the MIT License.
For inquiries, feedback, or collaborations, feel free to reach out via any of the following channels:
暂无开放 Issues,或尚未同步最近议题。