Skip to content
Pavan kumar edited this page Mar 24, 2015 · 6 revisions

pavankumar\qrcoder has many config options like size, frame margin, forecolor and background color of qrcode, output format, error correction level etc...

Changing the pixel size

By default the pixel size is 8, you can change the size of qrcode just by call setSize method on the qrcoder, below is the example

use PavanKumar\QrCoder\QrCoder;
Route:get('changesize',function(QrCoder $qrcoder){
   return $qrcoder->setSize('10')->generate("My size is 10 now");
});

Changing the margin size

for this you want to call setFrame method on qrcode, below is the example

use PavanKumar\QrCoder\QrCoder;
Route:get('changemargin',function(QrCoder $qrcoder){
   return $qrcoder->setFrame('10')->generate("My margin size is 10 now");
});

Changing the Fore Color

for this you want to call setColor method on qrcode, below is the example

use PavanKumar\QrCoder\QrCoder;
Route:get('changecolor',function(QrCoder $qrcoder){
   return $qrcoder->setColor('#00ff00')->generate("My fore color is now green");
});

Changing the Background Color

for this you want to call setBackColor method on qrcode, below is the example

use PavanKumar\QrCoder\QrCoder;
Route:get('changebackcolor',function(QrCoder $qrcoder){
   return $qrcoder->setBackColor('#0000ff')->generate("My background color is now blue");
});

Changing the Errorcorrection Level

for this you want to call setErrorCorrection method on qrcode, below is the example

use PavanKumar\QrCoder\QrCoder;
Route:get('changebackcolor',function(QrCoder $qrcoder){
   return $qrcoder->setErrorCorrection('Q')->generate("My error correction level is Q");
});

Changing the output Format

By default the generate method will generate the svg as the output format, you can change it by calling setFormat method below..

use PavanKumar\QrCoder\QrCoder;
Route:get('changebackcolor',function(QrCoder $qrcoder){
   return $qrcoder->setFormat('png')->generate("Im now png image");
});

one more thing is these all methods are chainable and set one after the other just as below

use PavanKumar\QrCoder\QrCoder;
Route:get('changebackcolor',function(QrCoder $qrcoder){
   return $qrcoder->setFormat('png')->setSize('10')->setColor('#ff000')->generate("Im now png image with size 10 and fore color is Red");
});

one thing you must remember is call the generate method after all your desired config's are set.