PHP code example of isahaq / barcode-qrcode-generator
1. Go to this page and download the library: Download isahaq/barcode-qrcode-generator 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/ */
isahaq / barcode-qrcode-generator example snippets
// Check if barcode type is supported
if (Barcode::isValidType('C128')) {
$barcode = Barcode::generatePNG('C128', '123456789');
}
// Check if QR code data is valid
if (QRCode::isValidData('https://example.com')) {
$qrCode = QRCode::generatePNG('https://example.com');
}
// Generate EAN-13 barcode for product
$productCode = '1234567890123';
$barcode = Barcode::generatePNG('EAN13', $productCode);
// Save to product images directory
Barcode::save('EAN13', $productCode, 'products/barcode.png', 'PNG');
// Generate vCard QR code
$vCard = "BEGIN:VCARD\nVERSION:3.0\nFN:John Doe\nTEL:+1234567890\nEMAIL:[email protected]\nEND:VCARD";
$qrCode = QRCode::generatePNG($vCard);
// Save to contacts directory
QRCode::save($vCard, 'contacts/john_doe.png', 'PNG');