定制 picoprime/barcodegen 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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\BarcodeGenerator class directly or PicoPrime\BarcodeGen\BarcodeGen facade. BarcodeGenerator can be injected as well. Before you call generate() method you have to pass variables to init() 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 picoprime/barcodegen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 16.84k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 89
  • 点击次数: 23
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 89
  • Watchers: 7
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-09-14