Skip to content

Simple test of generating a QR code for labels. Uses the chillerlan/php-qrcode generator Usage: composer require chillerlan/php-qrcode then open qrdemo.php in your web server.

License

Notifications You must be signed in to change notification settings

mrmonteith/QRCode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QRCode - Simple test of generating a QR code

Uses the chillerlan/php-qrcode generator

https://github.com/chillerlan/php-qrcode

image

Quick summary: This repository is a tiny PHP demo that generates a QR code using the chillerlan/php-qrcode library and prints it as an inline base64 PNG in an HTML <img> tag. Follow the steps below to install, run, and customize the example.

Project Overview

A minimal example showing how to generate a QR code in PHP using chillerlan/php-qrcode. The script loads Composer autoload, creates a QRCode instance, renders the supplied data to a base64 data URI, and prints an <img> tag so the QR appears directly in the browser. The library offers many configuration options and output formats for production use.

Features

  • Single-file demo for quick testing.
  • Base64 data URI output so no temporary files are required.
  • Easy to extend with QROptions for size, ECC level, colors, and different output backends.

Requirements

  • PHP 7.4+ (or the version supported by the library you install).
  • Composer to install dependencies.
  • Optional: ImageMagick or GD if you plan to use those output backends.

Installation

  1. Initialize Composer in your project folder if you haven’t already:
    composer init
  2. Require the chillerlan QR library:
    composer require chillerlan/php-qrcode
  3. Place the demo PHP file in your web root and ensure vendor/autoload.php is reachable.

The library repository and examples are a helpful reference for matching your installed version to example code.

Usage Example

Save this as qrdemo.php and open it in your browser:

<?php
use chillerlan\QRCode\QRCode;
require_once 'vendor/autoload.php';

$data   = '13534223';
$qrcode = (new QRCode)->render($data);

printf('<img src="%s" alt="QR Code" width="200px" height="200px" />', $qrcode);

This returns a base64 PNG data URI and embeds it in an <img> tag. A quick tutorial with similar examples is available online for reference and additional configuration tips.

Customization Notes

  • Use QROptions to set version, eccLevel (L, M, Q, H), scale, colors, and output interface (GD, Imagick, SVG, etc.).
  • To save to a file instead of a data URI, use the library’s saveToFile or output interface methods.
  • For logos, rounded modules, or advanced styling, check the examples folder in the repo for patterns you can adapt.

Troubleshooting

  • If the image does not display, inspect the HTML source to confirm the src contains a data:image/png;base64, URI.
  • Ensure required PHP extensions (GD or Imagick) are installed when using those backends.
  • Match examples to the library branch/version you installed to avoid API mismatches.

Resources and Examples

  • Official manual and configuration reference.
  • Example scripts and advanced demos in the project examples directory.
  • Community tutorial with quick-start snippets and configuration guidance.

License

License

This project is licensed under the MIT License. The chillerlan/php-qrcode library is open source; see its repository for license details.


About

Simple test of generating a QR code for labels. Uses the chillerlan/php-qrcode generator Usage: composer require chillerlan/php-qrcode then open qrdemo.php in your web server.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages