PHP code example of atelier / barcode

1. Go to this page and download the library: Download atelier/barcode 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/ */

    

atelier / barcode example snippets


echo QrCode::create('https://ateliersvg.com')->size(240)->render();

use Atelier\Barcode\Ecc;
use Atelier\Barcode\QrCode;

$svg = QrCode::create('https://ateliersvg.com')
    ->ecc(Ecc::Medium)
    ->size(240)
    ->margin(4)
    ->render();

file_put_contents('qr.svg', $svg);

use Atelier\Barcode\Code128;

echo Code128::create('ATELIER-2026')->render();

Ean13::create('4006381333931')
    ->scale(3)
    ->height(80)
    ->foreground('#14141c')
    ->background('transparent')
    ->render();

use Atelier\Barcode\Renderer\PngRenderer;

$png = PngRenderer::render(
    matrix: QrCode::create('https://ateliersvg.com')->matrix(),
    moduleSize: 6,
    margin: 4,
);

$grid = QrCode::create('hello')->matrix();   // array of rows of booleans
$bars = Code128::create('hello')->modules(); // bar and space widths

use Atelier\Barcode\Exception\CodeExceptionInterface;

try {
    echo QrCode::create($payload)->render();
} catch (CodeExceptionInterface $e) {
    // Invalid input, unsupported characters, a missing optional extension,
    // an invalid colour, or output dimensions beyond the safety limits.
}