peal/laravel-barcode-generator
Composer 安装命令:
composer require peal/laravel-barcode-generator
包简介
Barcode generate in Laravel
README 文档
README
Generate Barcode using Laravel & Core PHP
This package generate different types of barcode using Laravel as well as using core PHP.
Note: For this package you have to enable gd library.
Installation
Inside your project root directory, open your terminal
composer require Peal/laravel-barcode-generator
Composer will automatically download all dependencies.
For Laravel
After complete the installation, open your app.php from config folder, paste below line inside providers array
Peal\BarCodeGenerator\BarcodeServiceProvider::class,
For Facade support, paste below line inside aliases array
'BarCode' => peal\barcodegenerator\Facades\BarCode::class,
USAGES
//Generate into barcode folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; //Generate into customize folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'], $filepath = $barcode['filepath'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>';
Multiple barcode
//Generate into barcode folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; } //Generate into customize folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'], $filepath = $barcode['filepath'], )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; }
Using Facades
use peal\BarCodeGenerator\Facades\BarCode; //Single barcode //Generate into barcoce folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; //Generate into customize folder under public $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'], $filepath = $barcode['filepath'], )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; //Multiple barcode /** * For customize folder name, use filepath key and parameter */ $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; }
For core php
use Peal\BarCodeGenerator\Server\BarCodeServer; use Peal\BarCodeGenerator\BarCodeType\BarCode; //single 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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; //Multiple barcode $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'], // code_type : code128,code39,code128b,code128a,code25,codabar $print=$barcode['print'], $sizefactor=$barcode['sizefactor'], $filename = $barcode['filename'] )->filename($barcode['filename']); echo '<img alt="testing" src="'.$barcontent.'"/>'; }
Author
peal/laravel-barcode-generator 适用场景与选型建议
peal/laravel-barcode-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.37k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2018 年 08 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 peal/laravel-barcode-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 peal/laravel-barcode-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 17.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 18
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-09