milon / barcode
条码生成器,例如 Qr Code、PDF417、C39、C39+、C39E、C39E+、C93、S25、S25+、I25、I25+、C128、C128A、C128B、C128C、2-Digits UPC-Based Extention、5-Digits UPC-Based Extention、EAN 8、EAN 13、UPC-A、UPC-E、MSI(Plessey码的变体)
Requires
- php: ^7.3 | ^8.0
- illuminate/support: ^7.0|^8.0|^9.0|^10.0 | ^11.0
This package is auto-updated.
Last update: 2024-08-30 19:19:39 UTC
README
这是一个受https://github.com/tecnickcom/TCPDF启发的条码生成包。实际上,我使用了该包的底层类来生成条码。这个包只是那个包的包装,并增加了对Laravel 5的兼容性。
我使用了以下类。
- src/Milon/Barcode/Datamatrix.php (include/barcodes/datamatrix.php)
- src/Milon/Barcode/DNS1D.php (tcpdf_barcodes_1d.php)
- src/Milon/Barcode/DNS2D.php (tcpdf_barcodes_2d.php)
- src/Milon/Barcode/PDF417.php (include/barcodes/pdf417.php)
- src/Milon/Barcode/QRcode.php (include/barcodes/qrcode.php)
此包与Laravel 4.*
、5.*
、6.*
、7.*
、8.*
、9.*
、10.*
和11.*
兼容
此包依赖于php-gd扩展。因此,请确保它在您的机器上已安装。
安装
首先通过Composer安装此包。只需在终端运行以下命令即可-
composer require milon/barcode
您还可以编辑项目的composer.json
文件以需要milon/barcode
。
"require": { "milon/barcode": "^9.0" }
对于Laravel 8.*使用此-
"require": { "milon/barcode": "^8.0" }
对于Laravel 7.*使用此-
"require": { "milon/barcode": "^7.0" }
对于Laravel 6.*使用此-
"require": { "milon/barcode": "^6.0" }
对于Laravel 5.0和5.1使用此-
"require": { "milon/barcode": "^5.1" }
对于Laravel 4.0、4.1和4.2使用此-
"require": { "milon/barcode": "^4.2" }
接下来,从终端更新Composer
composer update
一旦此操作完成,最后一步是添加服务提供者。打开config/app.php
,并将新项目添加到提供者数组中。
'providers' => [ // ... Milon\Barcode\BarcodeServiceProvider::class, ]
对于版本4.*,在app/config/app.php
文件上添加以下行-
'providers' => array( // ... 'Milon\Barcode\BarcodeServiceProvider', )
如果您想更改条码的设置(存储路径等),则需要发布其配置文件。为此,您需要在终端中运行-
# Laravel 5.x php artisan vendor:publish # Laravel 4.x php artisan config:publish milon/barcode
确保您有权写入存储路径。默认情况下,它设置为/storage
文件夹。
现在添加别名。
'aliases' => [ // ... 'DNS1D' => Milon\Barcode\Facades\DNS1DFacade::class, 'DNS2D' => Milon\Barcode\Facades\DNS2DFacade::class, ]
对于版本4.2,别名将是这样的-
'aliases' => array( // ... 'DNS1D' => 'Milon\Barcode\Facades\DNS1DFacade', 'DNS2D' => 'Milon\Barcode\Facades\DNS2DFacade', )
条码生成器,例如Qr Code、PDF417、C39、C39+、C39E、C39E+、C93、S25、S25+、I25、I25+、C128、C128A、C128B、C128C、2-Digits UPC-Based Extention、5-Digits UPC-Based Extention、EAN 8、EAN 13、UPC-A、UPC-E、MSI(Plessey码的变体)
在html、png、jpeg中嵌入base64代码和SVG画布的生成器
echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T'); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T'); echo '<img src="data:image/png,' . DNS1D::getBarcodePNG('4', 'C39+') . '" alt="barcode" />'; echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T'); echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG('4', 'C39+') . '" alt="barcode" />'; echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T'); echo '<img src="data:image/jpeg;base64,' . DNS1D::getBarcodeJPG('4', 'C39+') . '" alt="barcode" />';
echo DNS1D::getBarcodeSVG('4445645656', 'C39'); echo DNS2D::getBarcodeHTML('4445645656', 'QRCODE'); echo DNS2D::getBarcodePNGPath('4445645656', 'PDF417'); echo DNS2D::getBarcodeSVG('4445645656', 'DATAMATRIX'); echo '<img src="data:image/png;base64,' . DNS2D::getBarcodePNG('4', 'PDF417') . '" alt="barcode" />';
宽度和高度示例
echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33); echo '<img src="' . DNS1D::getBarcodePNG('4', 'C39+',3,33) . '" alt="barcode" />'; echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33); echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG('4', 'C39+',3,33) . '" alt="barcode" />'; echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33); echo '<img src="data:image/jpeg;base64,' . DNS1D::getBarcodeJPG('4', 'C39+',3,33) . '" alt="barcode" />';
颜色
echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33,'green'); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33,'green'); echo '<img src="' . DNS1D::getBarcodePNG('4', 'C39+',3,33,array(1,1,1)) . '" alt="barcode" />'; echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0)); echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG('4', 'C39+',3,33,array(1,1,1)) . '" alt="barcode" />'; echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0)); echo '<img src="data:image/jpeg;base64,' . DNS1D::getBarcodeJPG('4', 'C39+',3,33,array(1,1,1)) . '" alt="barcode" />';
显示文本
echo DNS1D::getBarcodeSVG('4445645656', 'PHARMA2T',3,33,'green', true); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T',3,33,'green', true); echo '<img src="' . DNS1D::getBarcodePNG('4', 'C39+',3,33,array(1,1,1), true) . '" alt="barcode" />'; echo DNS1D::getBarcodePNGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0), true); echo '<img src="data:image/png;base64,' . DNS1D::getBarcodePNG('4', 'C39+',3,33,array(1,1,1), true) . '" alt="barcode" />'; echo DNS1D::getBarcodeJPGPath('4445645656', 'PHARMA2T',3,33,array(255,255,0), true); echo '<img src="data:image/jpeg;base64,' . DNS1D::getBarcodeJPG('4', 'C39+',3,33,array(1,1,1), true) . '" alt="barcode" />';
二维条码
echo DNS2D::getBarcodeHTML('4445645656', 'QRCODE'); echo DNS2D::getBarcodePNGPath('4445645656', 'PDF417'); echo DNS2D::getBarcodeSVG('4445645656', 'DATAMATRIX');
一维条码
echo DNS1D::getBarcodeHTML('4445645656', 'C39'); echo DNS1D::getBarcodeHTML('4445645656', 'C39+'); echo DNS1D::getBarcodeHTML('4445645656', 'C39E'); echo DNS1D::getBarcodeHTML('4445645656', 'C39E+'); echo DNS1D::getBarcodeHTML('4445645656', 'C93'); echo DNS1D::getBarcodeHTML('4445645656', 'S25'); echo DNS1D::getBarcodeHTML('4445645656', 'S25+'); echo DNS1D::getBarcodeHTML('4445645656', 'I25'); echo DNS1D::getBarcodeHTML('4445645656', 'I25+'); echo DNS1D::getBarcodeHTML('4445645656', 'C128'); echo DNS1D::getBarcodeHTML('4445645656', 'C128A'); echo DNS1D::getBarcodeHTML('4445645656', 'C128B'); echo DNS1D::getBarcodeHTML('4445645656', 'C128C'); echo DNS1D::getBarcodeHTML('4445645656', 'GS1-128'); echo DNS1D::getBarcodeHTML('44455656', 'EAN2'); echo DNS1D::getBarcodeHTML('4445656', 'EAN5'); echo DNS1D::getBarcodeHTML('4445', 'EAN8'); echo DNS1D::getBarcodeHTML('4445', 'EAN13'); echo DNS1D::getBarcodeHTML('4445645656', 'UPCA'); echo DNS1D::getBarcodeHTML('4445645656', 'UPCE'); echo DNS1D::getBarcodeHTML('4445645656', 'MSI'); echo DNS1D::getBarcodeHTML('4445645656', 'MSI+'); echo DNS1D::getBarcodeHTML('4445645656', 'POSTNET'); echo DNS1D::getBarcodeHTML('4445645656', 'PLANET'); echo DNS1D::getBarcodeHTML('4445645656', 'RMS4CC'); echo DNS1D::getBarcodeHTML('4445645656', 'KIX'); echo DNS1D::getBarcodeHTML('4445645656', 'IMB'); echo DNS1D::getBarcodeHTML('4445645656', 'CODABAR'); echo DNS1D::getBarcodeHTML('4445645656', 'CODE11'); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA'); echo DNS1D::getBarcodeHTML('4445645656', 'PHARMA2T');
不使用Laravel运行
您可以使用此库而不使用Laravel。
示例
use \Milon\Barcode\DNS1D; $d = new DNS1D(); $d->setStorPath(__DIR__.'/cache/'); echo $d->getBarcodeHTML('9780691147727', 'EAN13');
许可
此包根据GNU LGPLv3
许可证发布,版权归Nuruzzaman Milon所有。原始条码生成类由Nicola Asuni编写。许可协议在项目根目录中。
给我买杯咖啡 ☕
许可证:GNU LGPLv3
包作者:Nuruzzaman Milon
原始条码类作者:Nicola Asuni
软件包版权:Nuruzzaman Milon
条码生成类版权
Nicola Asuni
Tecnick.com LTD
www.tecnick.com