PHPackages                             apirone/php-qr-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. apirone/php-qr-code

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

apirone/php-qr-code
===================

Generate QR-codes from a single PHP file.

1.0.0(2y ago)112.6k↓37.8%11MITPHP

Since Jan 19Pushed 2y agoCompare

[ Source](https://github.com/Apirone/php-qr-code)[ Packagist](https://packagist.org/packages/apirone/php-qr-code)[ Docs](https://github.com/apirone/php-qr-code/)[ RSS](/packages/apirone-php-qr-code/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (1)

php QR Code generator library
=============================

[](#php-qr-code-generator-library)

- Generate QRcode from a single PHP file. MIT license.
- Output to raw PNG or base64 encoded data

Install
-------

[](#install)

```
composer require apirone/php-qr-code
```

Usage
-----

[](#usage)

```
require_once('../vendor/autoload.php';

use Apirone\Lib\PhpQrCode\QrCode;

// Quick static method with base64 encoded PNG

$data = 'Lorem ipsum dolor sit amet';
$options = [
    's' => 'qrm',
    'fc' => '#000000',
    'bc' => '#FFFFFF',
    // ...
];

$base64_qr_encoded = QrCode::png($data, $options);
echo ' ';

// Create and use qr instant
$qr = QRCode::init($data, $options); // $data & $options are optional

// Also you can use chain to set some options (not all)
$options['s'] = 'qrq';
$image_encoded = $qr->data($data)->options($options)->base64();

echo ' ';

$image_raw = QRCode::init()
    ->data($data)
    ->levelHigh()
    ->density(0.5)
    ->raw();

echo ' ';
```

Options
-------

[](#options)

Use options array to initialize class:

```
$options = [
    's' => 'qrl',
    'fc' => '#000000',
    'bc' => '#FFFFFF',
    // ...
];
```

### Available options keys

[](#available-options-keys)

You can define option as `[key => value, ...]` or use the option name as a property `$qr->s = 'qrl'`

- `s` - QR error correction level. Available values:

    - `qrl` - Level L (Low) 7% of data bytes can be restored.
    - `qrm` - Level M (Medium) 15% of data bytes can be restored.
    - `qrq` - Level Q (Quartile) 25% of data bytes can be restored.
    - `qrh` - Level H (High) 30% of data bytes can be restored.
- `w` - Width of image. Overrides `sf` or `sx`.
- `h` - Height of image. Overrides `sf` or `sy`.
- `sf` - Scale factor. Default 4.
- `sx` - Horizontal scale factor. Overrides `sf`.
- `sy` - Vertical scale factor. Overrides `sf`.
- `p` - Padding. Default is 0.
- `pv` - Top and bottom padding. Default is value of `p``.
- `ph` - Left and right padding. Default is value of `p`.
- `pt` - Top padding. Default is value of `pv`.
- `pl` - Left padding. Default is value of `ph`.
- `pr` - Right padding. Default is value of `ph`.
- `pb` - Bottom padding. Default is value of `pv`.
- `fc` - Foreground color in `#RRGGBB` format.
- `bc` - Background color in `#RRGGBB` format.
- `md` - Module density. A number between 0 and 1. Default is 1.
- `wq` - Width of quiet area units. Default is 1. Use 0 to suppress quiet area.
- `wm` - Width of narrow modules and spaces. Default is 1.

Methods
-------

[](#methods)

### Init methods. Static.

[](#init-methods-static)

- `png($data, $options = [])` - Convenience method to quickly generate an base64 encoded PNG. Static.
- `init($data = '', $options = [])` - Init QR code instance. Static.

### Set error correction levels

[](#set-error-correction-levels)

- `levelLow()` - Set `s` option to `qrl`.
- `levelMid()` - Set `s` option to `qrm`.
- `levelQrt()` - Set `s` option to `qrq`.
- `levelHigh()` - Set `s` option to `qrh`.
- `levelAuto()` - Unset `s` option.

### Some parameters setup methods

[](#some-parameters-setup-methods)

Call methods without params to clear options value.

- `data($data = '')` - Set QR code data
- `options($options = [])` - Set QR code options
- `size($size = null)` - Generated image size. Sets both `h` and `w` options to the same value.
- `scale($scale = null)` - Set `sf` option value.
- `padding($padding = null)` - Set `p` option.
- `color($color = null)` - Set `fc` option.
- `background($color = null)` - Set `bc` option.
- `quietZone($size = null)` - Set `wq` option.
- `density($density = null)` - Set `md` option.

### Generate QR methods

[](#generate-qr-methods)

- `render_image()` - Return generated GD resource.
- `raw()` - Return raw PNG image data.
- `base64()` - Return bse64 encoded PNG image data.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 81.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

850d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/99a86577f3815db177c5314e7f18690930353c499375a42503c85d2efa4cc5a7?d=identicon)[apirone.com](/maintainers/apirone.com)

---

Top Contributors

[![RebeccaRGB](https://avatars.githubusercontent.com/u/1642055?v=4)](https://github.com/RebeccaRGB "RebeccaRGB (9 commits)")[![cwchristerw](https://avatars.githubusercontent.com/u/13464896?v=4)](https://github.com/cwchristerw "cwchristerw (1 commits)")[![zaytseff](https://avatars.githubusercontent.com/u/1374234?v=4)](https://github.com/zaytseff "zaytseff (1 commits)")

### Embed Badge

![Health badge](/badges/apirone-php-qr-code/health.svg)

```
[![Health](https://phpackages.com/badges/apirone-php-qr-code/health.svg)](https://phpackages.com/packages/apirone-php-qr-code)
```

###  Alternatives

[hashids/hashids

Generate short, unique, non-sequential ids (like YouTube and Bitly) from numbers

5.5k48.6M278](/packages/hashids-hashids)[simplesoftwareio/simple-qrcode

Simple QrCode is a QR code generator made for Laravel.

2.9k27.6M92](/packages/simplesoftwareio-simple-qrcode)[meanbee/footerjs

Meanbee Footerjs module

14112.1k](/packages/meanbee-footerjs)[nonsapiens/realaddressfactory

Creates real-world street addresses from Google Maps, to use in database seeding, unit tests, or anything else. Supports Laravel 11+, and Faker

4910.2k7](/packages/nonsapiens-realaddressfactory)[phpsafari/health-checks

Make health checks in your laravel application

3713.2k](/packages/phpsafari-health-checks)[mjanssen/laravel-5-breadcrumbs

A simple and powerfull way to create breadcrumbs in Laravel 5+

1545.7k](/packages/mjanssen-laravel-5-breadcrumbs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
