0x01 包引入
安装 composer require picqer/php-barcode-generator 0.3
{ "require": { "picqer/php-barcode-generator": "^2.0" } }
0x02 测试代码
getBarcode($sample_code, $generator::TYPE_CODE_128, 2, 120); // $generatorSVG = new \Picqer\Barcode\BarcodeGeneratorSVG(); #创建SVG类型条形码 // $generatorPNG = new \Picqer\Barcode\BarcodeGeneratorPNG(); #创建PNG类型条形码 // $generatorJPG = new \Picqer\Barcode\BarcodeGeneratorJPG(); #创建JPG类型条形码 // $generatorHTML = new \Picqer\Barcode\BarcodeGeneratorHTML(); #创建HTML类型条形码 $redColor = [0, 0, 200]; $generator = new Picqer\Barcode\BarcodeGeneratorPNG(); $image_name = 'barcode'.mt_rand(100000,999999).'.png'; file_put_contents($image_name, $generator->getBarcode($sample_code, $generator::TYPE_CODE_128, 1, 100, $redColor));
0x03 效果展示
测试满足需求,可用!
0则评论给“php生成条形码”