PHP code example of brewerwall / php-barcode-generator

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

    

brewerwall / php-barcode-generator example snippets


$generator = new BarcodeGenerator(BarcodeType::TYPE_CODE_128, BarcodeRender::RENDER_JPG);

// Generate our code
$generated = $generator->generate('012345678');

// Generates the same code with style updates
$generated = $generator->generate('012345678', 4, 50, '#FFCC33');

use Brewerwall\Barcode\Constants\BarcodeRender;

BarcodeRender::RENDER_JPG
BarcodeRender::RENDER_PNG
BarcodeRender::RENDER_HTML
BarcodeRender::RENDER_SVG

use Brewerwall\Barcode\Constants\BarcodeType;

BarcodeType::TYPE_CODE_39
BarcodeType::TYPE_CODE_39_CHECKSUM
BarcodeType::TYPE_CODE_39E
BarcodeType::TYPE_CODE_39E_CHECKSUM
BarcodeType::TYPE_CODE_93
BarcodeType::TYPE_STANDARD_2_5
BarcodeType::TYPE_STANDARD_2_5_CHECKSUM
BarcodeType::TYPE_INTERLEAVED_2_5
BarcodeType::TYPE_INTERLEAVED_2_5_CHECKSUM
BarcodeType::TYPE_CODE_128
BarcodeType::TYPE_CODE_128_A
BarcodeType::TYPE_CODE_128_B
BarcodeType::TYPE_CODE_128_C
BarcodeType::TYPE_EAN_2
BarcodeType::TYPE_EAN_5
BarcodeType::TYPE_EAN_8
BarcodeType::TYPE_EAN_13
BarcodeType::TYPE_UPC_A
BarcodeType::TYPE_UPC_E
BarcodeType::TYPE_MSI
BarcodeType::TYPE_MSI_CHECKSUM
BarcodeType::TYPE_POSTNET
BarcodeType::TYPE_PLANET
BarcodeType::TYPE_RMS4CC
BarcodeType::TYPE_KIX
BarcodeType::TYPE_IMB
BarcodeType::TYPE_CODABAR
BarcodeType::TYPE_CODE_11
BarcodeType::TYPE_PHARMA_CODE
BarcodeType::TYPE_PHARMA_CODE_TWO_TRACKS

$generator = new BarcodeGenerator(BarcodeType::TYPE_CODE_128, BarcodeRender::RENDER_PNG);
echo '<img src="data:image/png;base64,' . base64_encode($generator->generate('012345678')) . '">';

composer