1. Go to this page and download the library: Download zoujingli/qrcode library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$result = \Endroid\QrCode\Builder\Builder::create()
->writer(new \Endroid\QrCode\Writer\PngWriter())
->writerOptions([])
->data('Custom QR code contents')
->encoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
->errorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelHigh())
->size(300)
->margin(10)
->roundBlockSizeMode(new \Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin())
->logoPath(__DIR__.'/icon.png')
->labelText('This is the label')
->labelFont(new \Endroid\QrCode\Label\Font\OpenSans(20))
->labelAlignment(new \Endroid\QrCode\Label\Alignment\LabelAlignmentCenter())
->validateResult(false)
->build();
$writer = new \Endroid\QrCode\Writer\PngWriter();
// Create QR code
$qrCode = \Endroid\QrCode\QrCode::create('Life is too short to be generating QR codes')
->setEncoding(new \Endroid\QrCode\Encoding\Encoding('UTF-8'))
->setErrorCorrectionLevel(new \Endroid\QrCode\ErrorCorrectionLevel\ErrorCorrectionLevelLow())
->setSize(300)
->setMargin(10)
->setRoundBlockSizeMode(new \Endroid\QrCode\RoundBlockSizeMode\RoundBlockSizeModeMargin())
->setForegroundColor(new \Endroid\QrCode\Color\Color(0, 0, 0))
->setBackgroundColor(new \Endroid\QrCode\Color\Color(255, 255, 255));
// Create generic logo
$logo = \Endroid\QrCode\Logo\Logo::create(__DIR__.'/icon.png')->setResizeToWidth(50);
// Create generic label
$label = \Endroid\QrCode\Label\Label::create('Label')
->setTextColor(new \Endroid\QrCode\Color\Color(255, 0, 0));
$result = $writer->write($qrCode, $logo, $label);
// Validate the result
$writer->validateResult($result, 'Life is too short to be generating QR codes');
// Directly output the QR code
header('Content-Type: '.$result->getMimeType());
echo $result->getString();
// Save it to a file
$result->saveToFile(__DIR__.'/qrcode.png');
// Generate a data URI to
use Endroid\QrCode\Writer\SvgWriter;
$builder->setWriterOptions([SvgWriter::WRITER_OPTION_EXCLUDE_XML_DECLARATION => true]);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.