yxy / y-qrcode
二维码生成
1.1.1
2025-03-12 01:19 UTC
Requires
- php: ^8.2
- endroid/qr-code: ^6.0
Requires (Dev)
- phpunit/phpunit: ^11.5
This package is not auto-updated.
Last update: 2025-04-10 00:12:31 UTC
README
生成二维码工具类
示例
/**
* @param array|string $content 内容
* @param int $type 输出方式 1 保存本地并返回路径 2 直接输出图片 3 输出base64的图片 默认直接输出图片
* @param int $size 大小 默认200
* @return array|string|null
**/
$content = [
"content" => "内容",
"level" => "等级 默认 high 1 Low 2 Medium 3 Quartile",
"margin" => "边距 默认 3",
"f_color" => "二维码景色 默认黑色 [0,0,0]",
"b_color" => "背景色 默认白色 [255,255,255]",
"logo" => "二维码logo 可只传字符串path或数组 ['路径','大小'] 或 ['path' => '路径','size' => 大小(数字)]",
"label" => "logo下方文字 可传字符串或数组 ['路径','颜色数组[0,0,0]'] 或 ['text' => '文字','color' => 颜色数组[0,0,0]]"
];
// 所有参数
Qrcode::create($content, 2, 200)
// 简单文字
Qrcode::create("你好")
// 配置二维码颜色和logo
Qrcode::create([
'content' => "https://www.baidu.com",
'f_color' => [10, 10, 10],
'logo' => 'D:/phpstudy_pro/WWW/backend-laravel-version/public/static/images/default_user.png',
])