PHP code example of peal / laravel-barcode-generator
1. Go to this page and download the library: Download peal/laravel-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' );
peal / laravel-barcode-generator example snippets
Peal\BarCodeGenerator\BarcodeServiceProvider::class,
'BarCode' => peal\barcodegenerator\Facades\BarCode::class,
$bar = App::make('BarCode' );
$barcodes = [
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
];
$barcontent = $bar->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
$bar = App::make('BarCode' );
$barcodes = [
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg' ,
'filepath' => 'prdbarcode'
];
$barcontent = $bar->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ],
$filepath = $barcode['filepath' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
$barcodes = [
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image2.jpeg'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image3.jpeg'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image4.jpeg'
],
];
foreach ($barcodes as $barcode) {
$bar = App::make('BarCode' );
$barcontent = $bar->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
}
$barcodes = [
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg' ,
'filepath' => 'prdbarcode'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image2.jpeg' ,
'filepath' => 'prdbarcode'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image3.jpeg' ,
'filepath' => 'prdbarcode'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image4.jpeg' ,
'filepath' => 'prdbarcode'
],
];
foreach ($barcodes as $barcode) {
$bar = App::make('BarCode' );
$barcontent = $bar->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ],
$filepath = $barcode['filepath' ],
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
}
use peal \BarCodeGenerator \Facades \BarCode ;
$barcodes = [
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
];
$barcontent = BarCode::barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
$barcodes = [
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg' ,
'filepath' => 'prdbarcode'
];
$barcontent = BarCode::barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ],
$filepath = $barcode['filepath' ],
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
$barcodes = [
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image2.jpeg'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image3.jpeg'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image4.jpeg'
],
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image5.jpeg'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image6.jpeg'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image7.jpeg'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image8.jpeg'
],
];
foreach ($barcodes as $barcode) {
$barcontent = BarCode::barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
}
use Peal \BarCodeGenerator \Server \BarCodeServer ;
use Peal \BarCodeGenerator \BarCodeType \BarCode ;
$barcodes = [
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
];
$barcontent = new BarCodeServer(new BarCode());
$barcontent = $barcontent->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
$barcodes = [
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image1.jpeg'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image2.jpeg'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image3.jpeg'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image4.jpeg'
],
[
'text' => 'HelloHello' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image5.jpeg'
],
[
'text' => 'HelloPeal' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image6.jpeg'
],
[
'text' => 'Hi Ruhul' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code128b' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image7.jpeg'
],
[
'text' => 'HelloMahian' ,
'size' => 50 ,
'orientation' => 'horizontal' ,
'code_type' => 'code39' ,
'print' => true ,
'sizefactor' => 1 ,
'filename' => 'image8.jpeg'
],
];
foreach ($barcodes as $barcode) {
$barcontent = new BarCodeServer(new BarCode());
$barcontent = $barcontent->barcodeFactory()->renderBarcode(
$text=$barcode["text" ],
$size=$barcode['size' ],
$orientation=$barcode['orientation' ],
$code_type=$barcode['code_type' ],
$print=$barcode['print' ],
$sizefactor=$barcode['sizefactor' ],
$filename = $barcode['filename' ]
)->filename($barcode['filename' ]);
echo '<img alt="testing" src="' .$barcontent.'"/>' ;
}