Generate QR Code In Codeignater

we are using the QR Code library. PHP QR Code is open source library for generating QR Code, 2-dimensional barcode. 

Now create a PHP file in the same folder where you placed the phpqrcode folder. We need to include ‘qrlib.php‘ file to use a function named ‘png()‘. This function is inside the QRcode class which outputs a QR code directly in the browser when we pass some text as a parameter.

Download PHP QR Code Library – download


QRcode::png(text, file, ecc, pixel_size, frame_size);

text – the text message which needs to be in a QR code,
file – location to save the generated QR code,
ecc – to specify the error correction capability of the QR code, it has four levels: L, M, Q and H,
pixel_size – to specify the pixel size of QR,
frame_size – to specify the size of the QR.

Using Codignater Controller

class Amd_qrganarate extends CI_Controller
	function __construct()

	public function GenerateQrAmd()  
		$qrtext = "upi://[email protected]&pn=AbdulMohammad&tr=GTZ272727&am=350&cu=INR&mc=5411";
		   	echo $SERVERFILEPATH = $_SERVER['DOCUMENT_ROOT'].'/assets/qr-amd/';
			$text = $qrtext;
			$text1= substr($text, 0,9);  
			$folder = $SERVERFILEPATH;
			$file_name1 = "testing-Qrcode" . rand(2,400) . ".png";
			$file_name = $folder.$file_name1;
					echo"<center><img src=".base_url().'assets/qr-amd/'.$file_name1."></center";
			echo 'No Text Entered';


Leave a Reply

Your email address will not be published.