PHPackages                             grscl/php-qrcode - 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. grscl/php-qrcode

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

grscl/php-qrcode
================

A QR code generator and reader with a user friendly API. PHP 7.4+

0128PHP

Since Jan 19Pushed 3y agoCompare

[ Source](https://github.com/grscl/php-qrcode)[ Packagist](https://packagist.org/packages/grscl/php-qrcode)[ RSS](/packages/grscl-php-qrcode/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

chillerlan/php-qrcode
=====================

[](#chillerlanphp-qrcode)

A PHP QR Code library based on the [implementation by Kazuhiko Arase](https://github.com/kazuhikoarase/qrcode-generator), namespaced, cleaned up, improved and other stuff. It also features a QR Code reader which is based on the [ZXing library](https://github.com/zxing/zxing).

**Attention:** there is now also a javascript port: [chillerlan/js-qrcode](https://github.com/chillerlan/js-qrcode).

[![PHP Version Support](https://camo.githubusercontent.com/04d1187595485712e2c4f20b2053b513481e324716db882a873b576b9ed0e44d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6368696c6c65726c616e2f7068702d7172636f64653f6c6f676f3d70687026636f6c6f723d383839324246)](https://www.php.net/supported-versions.php)[![Packagist version](https://camo.githubusercontent.com/aa5829b7834b343e83bedf64253c8a610a806af4c2a27bbc2ccc85ba4c436839/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6368696c6c65726c616e2f7068702d7172636f64652e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-qrcode)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](https://github.com/chillerlan/php-qrcode/blob/main/LICENSE-MIT)[![Continuous Integration](https://camo.githubusercontent.com/6756dc4bf9f43dcb5b1e3deae13f99e2b6880dd8aedb9b258792956dcaec934b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6368696c6c65726c616e2f7068702d7172636f64652f74657374732e796d6c3f6272616e63683d6d61696e266c6f676f3d676974687562)](https://github.com/chillerlan/php-qrcode/actions/workflows/tests.yml?query=branch%3Amain)[![CodeCov](https://camo.githubusercontent.com/7bff398040a322926ed0784547c0ad6489823a8487f835e5433a434eef87609d/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f6368696c6c65726c616e2f7068702d7172636f64652e7376673f6c6f676f3d636f6465636f76)](https://codecov.io/github/chillerlan/php-qrcode)[![Scrunitizer CI](https://camo.githubusercontent.com/a96b936456a254619bfaf5260815103b7464adfb03ca6a31c26109d954e5cae7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6368696c6c65726c616e2f7068702d7172636f64652e7376673f6c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/chillerlan/php-qrcode)[![Packagist downloads](https://camo.githubusercontent.com/be676adaa06a668521fa7a9d8bbdfd7dc0c59858692c8b31638b08a260b256ab/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6368696c6c65726c616e2f7068702d7172636f64652e7376673f6c6f676f3d7061636b6167697374)](https://packagist.org/packages/chillerlan/php-qrcode/stats)

Features
--------

[](#features)

- Generation of [Model 2 QR Codes](https://www.qrcode.com/en/codes/model12.html), [Version 1 to 40](https://www.qrcode.com/en/about/version.html)
- [ECC Levels](https://www.qrcode.com/en/about/error_correction.html) L/M/Q/H supported
- Mixed mode support (encoding modes can be mixed as needed within a QR symbol)
- Flexible, easily extensible output modules
- Built-in support for the following output formats:
    - [GdImage](https://www.php.net/manual/book.image)
    - [ImageMagick](https://www.php.net/manual/book.imagick)
    - Markup types: SVG, HTML, etc.
    - String types: JSON, plain text, etc.
    - Encapsulated Postscript (EPS)
    - PDF via [FPDF](https://github.com/setasign/fpdf)
- QR Code reader (via GD and ImageMagick)

Documentation
-------------

[](#documentation)

See [the wiki](https://github.com/chillerlan/php-qrcode/wiki) for advanced documentation. An API documentation created with [phpDocumentor](https://www.phpdoc.org/) can be found at  (WIP).

### Requirements

[](#requirements)

- PHP 7.4+
    - [`ext-mbstring`](https://www.php.net/manual/book.mbstring.php)
    - optional:
        - [`ext-gd`](https://www.php.net/manual/book.image)
        - [`ext-imagick`](https://github.com/Imagick/imagick) with [ImageMagick](https://imagemagick.org) installed
        - [`setasign/fpdf`](https://github.com/setasign/fpdf) for the PDF output module

For the QRCode reader, either `ext-gd` or `ext-imagick` is required!

### Installation

[](#installation)

**requires [composer](https://getcomposer.org)**

via terminal:

```
composer require chillerlan/php-qrcode

```

via `composer.json`:

```
{
	"require": {
		"php": "^7.4 || ^8.0",
		"chillerlan/php-qrcode": "dev-main"
	}
}
```

Note: replace `dev-main` with a [version constraint](https://getcomposer.org/doc/articles/versions.md#writing-version-constraints), e.g. `^4.3` - see [releases](https://github.com/chillerlan/php-qrcode/releases) for valid versions. See [the installation guide on the wiki](https://github.com/chillerlan/php-qrcode/wiki/Installation) for more info!

### Quickstart

[](#quickstart)

We want to encode this URI for a mobile authenticator into a QRcode image:

```
$data = 'otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net';

// quick and simple:
echo '';
```

 [![QR codes are awesome!](https://raw.githubusercontent.com/chillerlan/php-qrcode/main/.github/images/example.svg)](https://raw.githubusercontent.com/chillerlan/php-qrcode/main/.github/images/example.svg)

Wait, what was that? Please again, slower! See [Advanced usage](https://github.com/chillerlan/php-qrcode/wiki/Advanced-usage) on the wiki. Also, have a look [in the examples folder](https://github.com/chillerlan/php-qrcode/tree/main/examples) for some more usage examples.

### Reading QR Codes

[](#reading-qr-codes)

Using the built-in QR Code reader is pretty straight-forward:

```
$result = (new QRCode)->readFromFile('path/to/file.png'); // -> DecoderResult

// you can now use the result instance...
$content = $result->data;
$matrix  = $result->getMatrix(); // -> QRMatrix

// ...or simply cast it to string to get the content:
$content = (string)$result;
```

It's generally a good idea to wrap the reading in a try/catch block to handle any errors that may occur in the process.

### Framework Integration

[](#framework-integration)

- Drupal:
    - [Google Authenticator Login `ga_login`](https://www.drupal.org/project/ga_login)
- Symfony
    - [phpqrcode-bundle](https://github.com/jonasarts/phpqrcode-bundle)
- WordPress:
    - [wp-two-factor-auth](https://github.com/sjinks/wp-two-factor-auth)
    - [simple-2fa](https://wordpress.org/plugins/simple-2fa/)
    - [floating-share-button](https://github.com/qriouslad/floating-share-button)
- WoltLab Suite
    - [two-step-verification](http://pluginstore.woltlab.com/file/3007-two-step-verification/)
- other uses:
    - [dependents](https://github.com/chillerlan/php-qrcode/network/dependents) / [packages](https://github.com/chillerlan/php-qrcode/network/dependents?dependent_type=PACKAGE)
    - [Appwrite](https://github.com/appwrite/appwrite)
    - [Cachet](https://github.com/CachetHQ/Cachet)
    - [GÉANT CAT](https://github.com/GEANT/CAT)
    - [openITCOCKPIT](https://github.com/it-novum/openITCOCKPIT)
    - [twill](https://github.com/area17/twill)

### Shameless advertising

[](#shameless-advertising)

Hi, please check out my other projects that are way cooler than qrcodes!

- [php-oauth-core](https://github.com/chillerlan/php-oauth-core) - an OAuth 1/2 client library along with a bunch of [providers](https://github.com/chillerlan/php-oauth-providers)
- [php-httpinterface](https://github.com/chillerlan/php-httpinterface) - a PSR-7/15/17/18 implemetation
- [php-database](https://github.com/chillerlan/php-database) - a database client &amp; querybuilder for MySQL, Postgres, SQLite, MSSQL, Firebird

### Disclaimer!

[](#disclaimer)

I don't take responsibility for molten CPUs, misled applications, failed log-ins etc.. Use at your own risk!

#### License notice

[](#license-notice)

Parts of this code are [ported to php](https://github.com/khanamiryan/php-qrcode-detector-decoder) from the [ZXing project](https://github.com/zxing/zxing) and licensed under the [Apache License, Version 2.0](./NOTICE).

#### Trademark Notice

[](#trademark-notice)

The word "QR Code" is a registered trademark of *DENSO WAVE INCORPORATED*

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 98.6% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2ae4b0745a672eadb242a254491e3426218a5785a2a9e81f11b4cdc251e06684?d=identicon)[grscl](/maintainers/grscl)

---

Top Contributors

[![codemasher](https://avatars.githubusercontent.com/u/592497?v=4)](https://github.com/codemasher "codemasher (794 commits)")[![MaximilianKresse](https://avatars.githubusercontent.com/u/545671?v=4)](https://github.com/MaximilianKresse "MaximilianKresse (5 commits)")[![joshstoik1](https://avatars.githubusercontent.com/u/403248?v=4)](https://github.com/joshstoik1 "joshstoik1 (2 commits)")[![grscl](https://avatars.githubusercontent.com/u/307638?v=4)](https://github.com/grscl "grscl (1 commits)")[![kmvan](https://avatars.githubusercontent.com/u/3839554?v=4)](https://github.com/kmvan "kmvan (1 commits)")[![darthmaim](https://avatars.githubusercontent.com/u/2511547?v=4)](https://github.com/darthmaim "darthmaim (1 commits)")[![Trismegiste](https://avatars.githubusercontent.com/u/1260026?v=4)](https://github.com/Trismegiste "Trismegiste (1 commits)")

### Embed Badge

![Health badge](/badges/grscl-php-qrcode/health.svg)

```
[![Health](https://phpackages.com/badges/grscl-php-qrcode/health.svg)](https://phpackages.com/packages/grscl-php-qrcode)
```

###  Alternatives

[yajra/laravel-datatables-editor

Laravel DataTables Editor plugin for Laravel 5.5+.

1186.1M2](/packages/yajra-laravel-datatables-editor)[tu6ge/voyager-excel

voyager excel export hook

214.9k](/packages/tu6ge-voyager-excel)

PHPackages © 2026

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