Sunday, December 30, 2012

php script to generate qr code

php script to generate qr code


Overview

PHP QR Code is open source (LGPL) library for generating QR Code, 2-dimensional barcode. Based on libqrencode C library, provides API for creating QR Code barcode images (PNG, JPEG thanks to GD2). Implemented purely in PHP, with no external dependencies (except GD2 if needed).

Some of library features includes:

  • Supports QR Code versions (size) 1-40
  • Numeric, Alphanumeric, 8-bit and Kanji encoding. (Kanji encoding was not fully tested, if you are japan-encoding enabled you can contribute by verifing it :) )
  • Implemented purely in PHP, no external dependencies except GD2
  • Exports to PNG, JPEG images, also exports as bit-table
  • TCPDF 2-D barcode API integration
  • Easy to configure
  • Data cache for calculation speed-up
  • Provided merge tool helps deploy library as a one big dependency-less file, simple to "include and do not wory"
  • Debug data dump, error logging, time benchmarking
  • 100% Open Source, LGPL Licensed

Usage

To install simply include:

  • qrlib.php for full version (also you have to provide all library files form package plus cache dir)
  • OR phpqrcode.php for merged version (only one file, but slower and less accurate code because disabled cache and quicker masking configured)

Then use it as follows: 

QRcode::png('code data text', 'filename.png'); // creates file 
QRcode::png('some othertext 1234'); // creates code image and outputs it directly into browser

Above examples show the most basic usage. For more features and customization see PHP QR Code wiki or read INSTALL file in distrribution package.

No comments:

Post a Comment