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

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

phalapi/qrcode
==============

PhalApi 2.x 扩展类库：基于QRCode实现的二维码扩展

712.4k↓50%4[1 issues](https://github.com/phalapi/qrcode/issues)1PHP

Since Dec 29Pushed 8y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (1)

二维码扩展
=====

[](#二维码扩展)

PhalApi 二维码扩展，基于[PHP QRCode](http://phpqrcode.sourceforge.net)实现。可用于生成二维码图片。

安装和配置
-----

[](#安装和配置)

修改项目下的composer.json文件，并添加：

```
    "phalapi/qrcode":"dev-master"

```

然后执行`composer update`。

注册
--

[](#注册)

在/path/to/phalapi/config/di.php文件中，注册：

```
$di->qrcode = function() {
    return new \PhalApi\QrCode\Lite();
};
```

使用
--

[](#使用)

第一种使用方式：直接输出二维码图片：

```
\PhalApi\DI()->qrcode->png('Hello PhalApi!', false, 'L', 4);
```

效果类似如下：
[![](https://camo.githubusercontent.com/1ac7d853d37360514c00eed77fbf49be9dd014ff19616562d1839f60a2955968/687474703a2f2f3778697a32662e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f32303137313132313232353732325f3962386634386633393836653230323633363335383464626137633536363231)](https://camo.githubusercontent.com/1ac7d853d37360514c00eed77fbf49be9dd014ff19616562d1839f60a2955968/687474703a2f2f3778697a32662e636f6d312e7a302e676c622e636c6f7564646e2e636f6d2f32303137313132313232353732325f3962386634386633393836653230323633363335383464626137633536363231)

或者直接浏览器访问：[http://api.phalapi.net/?s=QrCode.Png&amp;data=Hello%20PhalApi!&amp;size=10](http://api.phalapi.net/?s=QrCode.Png&data=Hello%20PhalApi!&size=10)

第二种使用方式：将二维码图片保存到文件。

```
\PhalApi\DI()->qrcode->png('Hello PhalApi!', '/path/to/your_file.png', 'L', 4);

```

代码示例
----

[](#代码示例)

可参考[PhalApi的示例源代码](https://github.com/phalapi/phalapi/blob/master-2x/src/app/Api/Examples/QrCode.php)。

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 85.7% 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/35d70b1236f8f67d96ba3da4ba88889faf2837ff8f7ab62acc54fe6cb4992c87?d=identicon)[dogstarhuang](/maintainers/dogstarhuang)

---

Top Contributors

[![dogstarTest](https://avatars.githubusercontent.com/u/6116306?v=4)](https://github.com/dogstarTest "dogstarTest (6 commits)")[![phalapi](https://avatars.githubusercontent.com/u/12585518?v=4)](https://github.com/phalapi "phalapi (1 commits)")

### Embed Badge

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

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

PHPackages © 2026

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