Generates QR Codes

Fund package maintenance!

0.4.0 2023-05-19 20:33 UTC

This package is auto-updated.

Last update: 2024-05-24 21:30:18 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 have any questions, feel free to contact us under

Further information about Bit&Black can be found under