|
| 1 | +# globus-studio/phpqrcode |
| 2 | + |
| 3 | +Zero-dependency QR Code generator for PHP 7.4–9.0. |
| 4 | + |
| 5 | +[](https://github.com/MADEVAL/phpqrcode/actions) |
| 6 | +[](https://codecov.io/gh/MADEVAL/phpqrcode) |
| 7 | +[](https://packagist.org/packages/globus-studio/phpqrcode) |
| 8 | +[](LICENSE) |
| 9 | + |
| 10 | +## Features |
| 11 | + |
| 12 | +- Dead simple API — one line to generate QR |
| 13 | +- Zero runtime dependencies |
| 14 | +- PHP 7.4 / 8.0 / 8.1 / 8.2 / 8.3 / 8.4 / 8.5 / 9.0 |
| 15 | +- QR Code versions 1–40, all error correction levels |
| 16 | +- Multiple output formats: SVG, PNG, HTML, ASCII, raw matrix |
| 17 | +- 100% test coverage |
| 18 | +- PHPStan level max |
| 19 | +- PSR-4 autoloading |
| 20 | + |
| 21 | +## Installation |
| 22 | + |
| 23 | +```bash |
| 24 | +composer require globus-studio/phpqrcode |
| 25 | +``` |
| 26 | + |
| 27 | +## Usage |
| 28 | + |
| 29 | +```php |
| 30 | +use GlobusStudio\QRCode\QRCode; |
| 31 | + |
| 32 | +// SVG string |
| 33 | +$svg = QRCode::svg('https://example.com'); |
| 34 | + |
| 35 | +// PNG as data URI (requires ext-gd) |
| 36 | +$png = QRCode::png('https://example.com'); |
| 37 | + |
| 38 | +// HTML table |
| 39 | +$html = QRCode::html('https://example.com'); |
| 40 | + |
| 41 | +// ASCII art |
| 42 | +echo QRCode::string('https://example.com'); |
| 43 | + |
| 44 | +// Raw boolean matrix |
| 45 | +$matrix = QRCode::matrix('https://example.com'); |
| 46 | +``` |
| 47 | + |
| 48 | +## Options |
| 49 | + |
| 50 | +```php |
| 51 | +use GlobusStudio\QRCode\QRCode; |
| 52 | +use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel; |
| 53 | + |
| 54 | +$svg = QRCode::svg('data', [ |
| 55 | + 'level' => ErrorCorrectionLevel::H, |
| 56 | + 'size' => 4, |
| 57 | + 'margin' => 2, |
| 58 | + 'foreground' => '#000000', |
| 59 | + 'background' => '#ffffff', |
| 60 | +]); |
| 61 | +``` |
| 62 | + |
| 63 | +## Object API |
| 64 | + |
| 65 | +```php |
| 66 | +use GlobusStudio\QRCode\QRCode; |
| 67 | +use GlobusStudio\QRCode\ErrorCorrection\ErrorCorrectionLevel; |
| 68 | +use GlobusStudio\QRCode\Renderer\SvgRenderer; |
| 69 | + |
| 70 | +$qr = new QRCode('https://example.com', ErrorCorrectionLevel::H); |
| 71 | +$svg = $qr->render(new SvgRenderer(['size' => 6])); |
| 72 | +$matrix = $qr->getMatrix(); |
| 73 | +``` |
| 74 | + |
| 75 | +## Error Correction Levels |
| 76 | + |
| 77 | +| Level | Recovery | |
| 78 | +|-------|----------| |
| 79 | +| L | ~7% | |
| 80 | +| M | ~15% | |
| 81 | +| Q | ~25% | |
| 82 | +| H | ~30% | |
| 83 | + |
| 84 | +## Renderers |
| 85 | + |
| 86 | +| Renderer | Dependencies | Output | |
| 87 | +|----------|-------------|--------| |
| 88 | +| SvgRenderer | none | SVG XML string | |
| 89 | +| HtmlRenderer | none | HTML table | |
| 90 | +| StringRenderer | none | ASCII/UTF-8 | |
| 91 | +| PngRenderer | ext-gd | PNG binary | |
| 92 | +| RawRenderer | none | JSON / int[][] | |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +MIT — see [LICENSE](LICENSE). |
0 commit comments