定制 golivehost/php-qrcodegen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

golivehost/php-qrcodegen

最新稳定版本:v0.1.1

Composer 安装命令:

composer require golivehost/php-qrcodegen

包简介

A simple PHP library to generate QR codes using the GoLive.host QR Generator API.

README 文档

README

GoLiveHost PHP QR Code Generator is a simple PHP library designed to easily generate QR codes using the GoLive.host QR Generator API.

Requirements

  • cURL extension enabled in PHP
  • PHP version: 7.3 or higher (compatible with PHP 8.0+)

Installation

To install this library, use Composer. Run the following command:

composer require golivehost/php-qrcodegen

This will download and install the library and its dependencies into your project.

Usage

Example 1: Generate QR Code with Label

This example demonstrates how to generate a QR code with a label below it.

<?php

// Include Composer's autoloader
require 'vendor/autoload.php';

use GoLiveHost\QRCodeGen\QRCodeGenerator;

// Instantiate the QRCodeGenerator class
$golivehost = new QRCodeGenerator();

// Set data to encode in the QR code
$golivehost->setData('Sample data for the QR code');

// Set QR code size
$golivehost->setSize('300x300');

// Set label for the QR code
$golivehost->setLabel('Sample QR Code Label');

// Save the generated QR code
$golivehost->saveQR('qr_code_with_label.png');

echo "QR code with label saved as qr_code_with_label.png\n";

Example 2: Generate QR Code without Label

This example demonstrates how to generate a QR code without a label.

<?php

// Include Composer's autoloader
require 'vendor/autoload.php';

use GoLiveHost\QRCodeGen\QRCodeGenerator;

// Instantiate the QRCodeGenerator class
$golivehost = new QRCodeGenerator();

// Set data to encode in the QR code
$golivehost->setData('Sample data for the QR code');

// Set QR code size
$golivehost->setSize('300x300');

// Do not set any label for the QR code
$golivehost->saveQR('qr_code_without_label.png');

echo "QR code without label saved as qr_code_without_label.png\n";

Utility: Generate and Save QR Code (One-liner)

You can also use the utility class for a simpler approach.

<?php

// Include Composer's autoloader
require 'vendor/autoload.php';

use GoLiveHost\QRCodeGen\QRCodeUtils;

// Generate and save the QR code with a label
QRCodeUtils::generateAndSave('Sample data for the QR code', 'qr_code_sample.png', '300x300', 'Sample QR Code Label');

echo "QR code with label saved as qr_code_sample.png\n";

API Documentation

The GoLive.host QR Code Generator API allows you to generate QR codes. The full documentation for the API can be found here:

GoLive.host QR Code Generator API Docs

License

This library is licensed under the GoSecuredns Open License.

统计信息

  • 总下载量: 51
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-01-10