picoprime/barcodegen
最新稳定版本:1.5
Composer 安装命令:
composer require picoprime/barcodegen
包简介
Generates barcodes images as PNG or DATA-URL
README 文档
README
WARNING!
THIS PROJECT IS NO LONGER MAINTAINED!
WARNING!
Barcode Generator is a simple library that helps you create barcodes images. It's designed for Laravel 5 and it can create PNG images or DATA-URL strings. Based on great php-generator by David Tufts
Installation
Through Composer, obviously:
composer require picoprime/barcodegen
or you can edit composer.json file and add "picoprime/barcodegen": "~1.5" to
your "require" section.
Setup
Successfully tested in Laravel 5. Steps to make it work:
- edit "require" section in composer.json as described above
- Ignore this step on Laravel 5.5 or newer - package will be auto discovered
edit config/app.php file and add
PicoPrime\BarcodeGen\BarcodeGenServiceProvider::class,to providers - create controller or add new methods to existing controllers (example is in "docs"
folder). You can use
PicoPrime\BarcodeGen\BarcodeGeneratorclass directly orPicoPrime\BarcodeGen\BarcodeGenfacade.BarcodeGeneratorcan be injected as well. Before you callgenerate()method you have to pass variables toinit()like so:
$this->barcode
->init($text, $size, $orientation, $codeType, $scale)
->generate()
or with facade and direct generate call:
\PicoPrime\BarcodeGen\BarcodeGen::generate($text, $size, $orientation, $codeType, $scale)
where:
- "text" is the text that you want to transform into barcode,
- "size" is barcode's height in pixels. If you need to change width as well then use "scale" together with "size"!
- "orientation" does what it says - changes barcode's orientation. Available: horizontal and vertical,
- "codeType" is the type of code that you want to generate. Available: code128, code128a, code39, code25, codabar.
- "scale" - if you need wider or just bigger barcode enter a number: 1 - default, 2 - 2x bigger, 2.5, ...
You can also pass these parameters as assoc or numeric array, like so:
$this->barcode
->generate(compact('text', 'size', 'orientation', 'codeType', 'scale'))
or using facade:
\PicoPrime\BarcodeGen\BarcodeGen::generate(['textToTransform', 50, 'horizontal', 'code128', 1])
Last step to generate image is to send whatever has been generated above
to ->response('png') or ->encode('data-url').
Response will create Laravel's response and will display an image, whilst
"encode" will create a string.
Please take a look at example controller in docs folder.
Routes
You can create routes as you like. Two examples that we usually use:
Route::get('barcode/img/{text}/{size?}/{scale?}/{codeType?}/{orientation?}', 'BarcodeController@barcodeAsPng');
Route::get('barcode/url/{text}/{size?}/{scale?}/{codeType?}/{orientation?}', 'BarcodeController@barcodeAsDataUrl');
Please take a look at example route in docs folder.
Frontend use
Finally to use it in frontend, just use your route in img "src" attribute:
<img src="/barcode/img/someText" alt="barcode">
This example should generate horizontal, 50px, code128 barcode for "someText".
Issues
Please feel free to create an issue on GitHub if you come across any errors or if you have an idea for improvement.
Enjoy
Oh and if you've come down this far, you might as well follow me on twitter or check out my company's website.
picoprime/barcodegen 适用场景与选型建议
picoprime/barcodegen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 16.84k 次下载、GitHub Stars 达 89, 最近一次更新时间为 2015 年 09 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「image」 「barcode」 「png」 「barcodes」 「generate」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 picoprime/barcodegen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 picoprime/barcodegen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 picoprime/barcodegen 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Bundle providing a password encoder stack for support of legacy user data.
Symfony 4, 5, 6 ,7 Barcode Generator Bundle with Twig function extension
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
GS1 parser and generator for PHP
统计信息
- 总下载量: 16.84k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 89
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-09-14