I have been using google qrcode api for sometime, but I didn't quite like this because it requires me to be on the Internet to access the generated image.
I did a little comand-line research and found out that linux has a command line tool qrencode
for generating qr-codes.
I wrote this little script. And the good part is that the generated image is less than 1KB in size. Well the supplied data is simply a url.
$url = ($_SERVER['HTTPS'] ? "https://" : "http://").$_SERVER['HTTP_HOST'].'/profile.php?id='.$_GET['pid'];
$img = shell_exec('qrencode --output=- -m=1 '.escapeshellarg($url));
$imgData = "data:image/png;base64,".base64_encode($img);
Then in the html I load the image:
<img class="emrQRCode" src="<?=$imgData ?>" />
You just need to have installed it. [most imaging apps on linux would have installed it under the hood without you realizing.