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

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

zoujingli/qrcode
================

Endroid QrCode for ThinkAdmin

v1.0.3(2y ago)016.2k↑45.8%5MITPHPPHP ^7.1|^8.0

Since Jan 2Pushed 1y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (1)Versions (4)Used By (5)

二维码工具 QrCode
============

[](#二维码工具-qrcode)

[![Latest Stable Version](https://camo.githubusercontent.com/56a94271475bfaaf25ef54bc273cdbf2e8a8fdeac909552a642617fa693c70d4/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a6f756a696e676c692f7172636f64652e737667)](https://packagist.org/packages/zoujingli/qrcode)[![Latest Unstable Version](https://camo.githubusercontent.com/8d3de2406e634c87081b4dc01ce529e45d4eb1983811436f228e919445185de7/68747470733a2f2f706f7365722e707567782e6f72672f7a6f756a696e676c692f7172636f64652f762f756e737461626c65)](https://packagist.org/packages/zoujingli/qrcode)[![Total Downloads](https://camo.githubusercontent.com/59ec2e4f99e59181e0c2cfe8db91cb6bce952ce52d05394e45a9c0498726a4f1/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a6f756a696e676c692f7172636f64652e737667)](https://packagist.org/packages/zoujingli/qrcode)[![Monthly Downloads](https://camo.githubusercontent.com/ae4245d07a03e7d2a99f4f55056232cc44196c875165aab612a8417d3f6ccbb0/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f7a6f756a696e676c692f7172636f64652e737667)](https://packagist.org/packages/zoujingli/qrcode)[![License](https://camo.githubusercontent.com/ac0bfb01ab71b88963a7bd19199569fb6837d9a8f858609f198578901774f85e/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7a6f756a696e676c692f7172636f64652e737667)](https://packagist.org/packages/zoujingli/qrcode)

二维码工具`zoujingli/qrcode`是`fork`自`endroid/qr-code`进行修改来，最低支持`php7.1`版本；

详细文档见原仓库：

> **为满足在`PHP7`运行需求，对原仓库进行如下修改：**
>
> 1. 修改代码语法最低可在`PHP7.1`上运行；
> 2. 原仓库的开源协议不变，未增加额外功能代码；
> 3. 目前已测试`PHP`环境有`PHP7.1` `PHP7.2` `PHP7.4`；
> 4. 去除原仓库的部分测试代码及字体文件，优化安装包体积；

```
// 安装执行指令
composer require zoujingli/qrcode
```

常规配置如下，更多参数使用请阅读其官方文档。

```
$result = \Endroid\QrCode\Builder\Builder::create()
    ->writer(new \Endroid\QrCode\Writer\PngWriter())
    ->writerOptions([])
    ->data('Custom QR code contents')
    ->encoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
    // ->errorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh())
    ->size(300)
    ->margin(10)
    // ->roundBlockSizeMode(new \Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin())

    //// 设置二维码 LOGO 图片
    // ->logoPath(__DIR__.'/icon.png')

    //// 设置二维码标签字段
    // ->labelText('This is the label')
    // ->labelFont(new \Endroid\QrCode\Label\Font\OpenSans(20))
    // ->labelAlignment(new \Endroid\QrCode\Label\Alignment\LabelAlignmentCenter())
    ->validateResult(false)
    ->build();

// 输出 Base64 图片
echo $result->getDataUri();
```

#### Usage: using the builder

[](#usage-using-the-builder)

```
$result = \Endroid\QrCode\Builder\Builder::create()
    ->writer(new \Endroid\QrCode\Writer\PngWriter())
    ->writerOptions([])
    ->data('Custom QR code contents')
    ->encoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
    ->errorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh())
    ->size(300)
    ->margin(10)
    ->roundBlockSizeMode(new \Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin())
    ->logoPath(__DIR__.'/icon.png')
    ->labelText('This is the label')
     ->labelFont(new \Endroid\QrCode\Label\Font\OpenSans(20))
    ->labelAlignment(new \Endroid\QrCode\Label\Alignment\LabelAlignmentCenter())
    ->validateResult(false)
    ->build();
```

#### Usage: without using the builder

[](#usage-without-using-the-builder)

```
$writer = new \Endroid\QrCode\Writer\PngWriter();

// Create QR code
$qrCode = \Endroid\QrCode\QrCode::create('Life is too short to be generating QR codes')
    ->setEncoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
    ->setErrorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow())
    ->setSize(300)
    ->setMargin(10)
    ->setRoundBlockSizeMode(new \Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin())
    ->setForegroundColor(new \Endroid\QrCode\Color\Color(0, 0, 0))
    ->setBackgroundColor(new \Endroid\QrCode\Color\Color(255, 255, 255));

// Create generic logo
$logo = \Endroid\QrCode\Logo\Logo::create(__DIR__.'/icon.png')->setResizeToWidth(50);

// Create generic label
$label = \Endroid\QrCode\Label\Label::create('Label')
->setTextColor(new \Endroid\QrCode\Color\Color(255, 0, 0));

$result = $writer->write($qrCode, $logo, $label);

// Validate the result
$writer->validateResult($result, 'Life is too short to be generating QR codes');
```

#### Usage: working with results

[](#usage-working-with-results)

```
// Directly output the QR code
header('Content-Type: '.$result->getMimeType());
echo $result->getString();

// Save it to a file
$result->saveToFile(__DIR__.'/qrcode.png');

// Generate a data URI to include image data inline (i.e. inside an  tag)
$dataUri = $result->getDataUri();
```

##### Writer options

[](#writer-options)

```
use Endroid\QrCode\Writer\SvgWriter;

$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
```

##### Encoding

[](#encoding)

If you use a barcode scanner you can have some troubles while reading the generated QR codes. Depending on the encoding you chose you will have an extra amount of data corresponding to the ECI block. Some barcode scanner are not programmed to interpret this block of information. To ensure a maximum compatibility you can use the `ISO-8859-1` encoding that is the default encoding used by barcode scanners (if your character set supports it, i.e. no Chinese characters are present).

##### Round block size mode

[](#round-block-size-mode)

By default block sizes are rounded to guarantee sharp images and improve readability. However some other rounding variants are available.

- `margin (default)`: the size of the QR code is shrunk if necessary but the size of the final image remains unchanged due to additional margin being added.
- `enlarge`: the size of the QR code and the final image are enlarged when rounding differences occur.
- `shrink`: the size of the QR code and the final image are shrunk when rounding differences occur.
- `none`: No rounding. This mode can be used when blocks don't need to be rounded to pixels (for instance SVG).

#### Readability

[](#readability)

The readability of a QR code is primarily determined by the size, the input length, the error correction level and any possible logo over the image, so you can tweak these parameters if you are looking for optimal results. You can also check $qrCode-&gt;getRoundBlockSize() value to see if block dimensions are rounded so that the image is more sharp and readable. Please note that rounding block size can result in additional padding to compensate for the rounding difference. And finally the encoding (default UTF-8 to support large character sets) can be set to `ISO-8859-1` if possible to improve readability.

#### Validating the generated QR code

[](#validating-the-generated-qr-code)

If you need to be extra sure the QR code you generated is readable and contains the exact data you requested you can enable the validation reader, which is disabled by default. You can do this either via the builder or directly on any writer that supports validation. See the examples above.

Please note that validation affects performance so only use it in case of problems.

#### Symfony integration

[](#symfony-integration)

The [endroid/qr-code-bundle](https://github.com/endroid/qr-code-bundle)integrates the QR code library in Symfony for an even better experience.

- Configure your defaults (like image size, default writer etc.)
- Support for multiple configurations and injection via aliases
- Generate QR codes for defined configurations via URL like /qr-code//Hello
- Generate QR codes or URLs directly from Twig using dedicated functions

Read the [bundle documentation](https://github.com/endroid/qr-code-bundle)for more information.

#### Versioning

[](#versioning)

Version numbers follow the MAJOR.MINOR.PATCH scheme. Backwards compatibility breaking changes will be kept to a minimum but be aware that these can occur. Lock your dependencies for production and test your code when upgrading.

#### License

[](#license)

This bundle is under the MIT license. For the full copyright and license information please view the LICENSE file that was distributed with this source code.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance27

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

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

Every ~127 days

Total

3

Last Release

977d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c806d477ba01d9441023f3cc9a7c70e6491a189d0aae80bca2cc444691e31723?d=identicon)[zoujingli](/maintainers/zoujingli)

---

Top Contributors

[![zoujingli](https://avatars.githubusercontent.com/u/4349951?v=4)](https://github.com/zoujingli "zoujingli (11 commits)")

---

Tags

qrcodeendroid

### Embed Badge

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

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

###  Alternatives

[endroid/qr-code

Endroid QR Code

4.8k67.6M348](/packages/endroid-qr-code)[simplesoftwareio/simple-qrcode

Simple QrCode is a QR code generator made for Laravel.

2.9k27.6M92](/packages/simplesoftwareio-simple-qrcode)[linkxtr/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

295.1k](/packages/linkxtr-laravel-qrcode)[akira/laravel-qrcode

A clean, modern, and easy-to-use QR code generator for Laravel

431.4k](/packages/akira-laravel-qrcode)

PHPackages © 2026

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