Chillerlan/php–qrcode
基于Kazuhiko Arase的实现的PHP QR码生成器,命名,清理,改进和其他内容。
它还基于ZXing库的PHP端口具有QR码读取器。
注意:现在在NPM上还有一个JavaScript端口: @Chillerlan/QRCode。
概述
特征
- 模型2 QR码的创建,版本1至40版
- ECC水平L/M/Q/H支持
- 混合模式支持(可以将编码模式组合在QR符号中)。支持模式:
- 数字
- 字母数字
- 8位二进制
- ECI支持
- 13位双字节:
- 汉字(日语,换档)
- Hanzi(简化中文,GB2312/GB18030),如GBT18284-2000中所定义
- 灵活的,易于扩展的输出模块,内置支持以下输出格式:
- gdimage(栅格图形:AVIF,BMP,GIF,JPEG,PNG,WEBP)
- ImageMagick(多个支持的图像格式)
- 标记类型:SVG,HTML等。
- 字符串类型:JSON,纯文本等。
- 封装后记(EPS)
- PDF通过FPDF
- QR码阅读器(通过GD和ImageMagick)
要求
- PHP 8.2+
-
ext-mbstring - 选修的:
- 基于
QRGdImage的输出的ext-gd - 安装了ImageMagick的
ext-imagick -
QRImagick输出所需的ext-fileinfo - PDF输出模块的
setasign/fpdf - 替代GD/ImageMagick输出的
intervention/image
- 基于
-
对于QR码读取器,需要ext-gd或ext-imagick !
文档
- 用户手册位于https://php-qrcode.**r*eadthedocs.io/(源)
- 可以在https://chillerlan.g*ith**ub.io/php-qrcode/上找到使用phpdocumentor创建的API文档。
-
QROptions容器的文档在这里:Chillerlan/PHP-Settings-container - 基准结果可以在
benchmark分支中找到
重要的是:请使用与安装的PHP-QRCODE版本(v4.x,v5.x,dev-main)匹配的分支的示例!main (默认)分支是未来主要版本的主动开发,并且很可能与最新版本版本不兼容。
用作曲家安装
有关更多信息,请参见“安装指南”!
终端
composer require chillerlan/php-qrcode
作曲家
{
\"require\" : {
\"php\" : \" ^8.2 \" ,
\"chillerlan/php-qrcode\" : \" dev-main#<commit_hash> \"
}
}
注意:用版本约束替换dev-main ,例如^5.0有关有效版本,请参见发行版。
Quickstart
我们想将此URI编码为移动身份验证器中的QRCode映像:
$ data = \' otpauth://totp/test?secret=B3JX4VCVJDVNXNZ5&issuer=chillerlan.net \' ; // quick and simple: echo \' <img src=\" \' .( new QRCode )-> render ( $ data ). \' \" alt=\"QR Code\" /> \' ;
等等,那是什么?请再次慢慢!请参阅手册中的高级用法。另外,请查看示例文件夹以获取更多用法示例。
读取QR码
使用内置的QR代码读取器非常简单:
// it\'s generally a good idea to wrap the reader in a try/catch block because it WILL throw eventually try { $ 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 ; } catch ( Throwable $ e ){ // oopsies! }
无耻的广告
嗨,请查看我的其他一些比QRCodes凉爽的项目!
- JS -QRCODE-此库的JavaScript端口
- php -authenticator- Google Authenticator实现(请参阅身份验证示例)
- PHP-HTTPINTEFFACE- PSR-7/15/17/18插入
- PHP-OAUTH- OAUTH 1/2客户库,完全PSR-7/PSR-17/PSR-18兼容
- PHP数据库 – MySQL,Postgres,Sqlite,MSSQL,Firebird的数据库客户端和QueryBuilder
- php -tootbot- mastodon bot库(请参阅@dwil)
免责声明!
我不对熔融CPU,误导的应用程序,登录失败等负责。
许可通知
- 该代码的一部分从ZXing项目移植到PHP,并根据Apache许可证(版本2.0)获得许可。
- 该文档是根据创意共享归因4.0国际许可(CC By 4.0)许可的。
商标通知
“ QR码”一词是Denso Wave Incorporated的注册商标
https://www.q*r**code.com/en/faq.html#patenth2title
