1. Go to this page and download the library: Download phpdot/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/ */
phpdot / qrcode example snippets
use PHPdot\QrCode\QrCodeFactory;
final class TicketController
{
public function __construct(private readonly QrCodeFactory $qr) {}
public function qr(string $ticketId): string
{
return $this->qr->svg("https://phpdot.com/t/{$ticketId}");
}
}
use PHPdot\QrCode\Color;
use PHPdot\QrCode\Enum\ErrorCorrection;
$png = $qr->create('WIFI:T:WPA;S:phpdot;P:secret;;')
->errorCorrection(ErrorCorrection::High)
->size(512)
->margin(2)
->foreground(Color::fromHex('#101828'))
->background(Color::fromHex('#f8fafc'))
->toPng();
file_put_contents('wifi.png', $png);
use PHPdot\QrCode\Color;
Color::fromHex('#0b5'); // #rgb / #rrggbb / #rrggbbaa, '#' optional
Color::black();
Color::transparent(); // real alpha channel in the PNG
$svg = $qr->create('https://phpdot.com')
->background(Color::transparent())
->toSvg();