Generates QR Codes

0.2.1 2020-11-26 13:49 UTC

This package is auto-updated.

Last update: 2021-03-26 14:39:47 UTC


PHP from Packagist Codacy Badge Latest Stable Version Total Downloads License

QR Code

This library generates QR codes. It's based on endroid/qr-code by Jeroen van den Enden but differs by using bitandblack/colors to allow different color spaces.


This library is made for the use with Composer. Add it to your project by running $ composer require bitandblack/qr-code.



use BitAndBlack\QrCode\QrCode;

$qrCode = new QrCode('Hello World!');

header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();

Advanced usage


use Color\Value\RGB;
use BitAndBlack\QrCode\ErrorCorrectionLevel;
use BitAndBlack\QrCode\LabelAlignment;
use BitAndBlack\QrCode\QrCode;
use BitAndBlack\QrCode\Response\QrCodeResponse;

$qrCode = new QrCode('Hello World!');
        new ErrorCorrectionLevel(ErrorCorrectionLevel::HIGH())
        new RGB(0, 0, 0)
        new RGB(255, 255, 255)
    ->setLabel('Scan the code', 16, 'SomeFont.otf', LabelAlignment::CENTER)    
    ->setLogoSize(150, 200)    
        'exclude_xml_declaration' => true

// Directly output the QR code
header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();

// Save it to a file

// Create a response object
$response = new QrCodeResponse($qrCode);


If you need help feel free to contact us under