hbgl/php-code-128-encoder 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

hbgl/php-code-128-encoder

最新稳定版本:1.0.2

Composer 安装命令:

composer require hbgl/php-code-128-encoder

包简介

Encode text for use with Code 128 fonts such as Libre Barcode 128.

README 文档

README

CI Latest Stable Version

Encode text for use with Code 128 fonts such as Libre Barcode 128. The actual encoding is done by tc-lib-barcode.

Installation

Install PHP Code 128 Encoder using Composer:

composer require hbgl/php-code-128-encoder

Usage

<?php

require __DIR__ . '/../vendor/autoload.php';

use Hbgl\Barcode\Code128Encoder;

// Encode as Code 128.
$encoded = Code128Encoder::encode('ABC123456DEF');
assert ($encoded === 'ÌABCÇ,BXÈDEFqÎ');

// Only encode using Type A.
$encodedA = Code128Encoder::encode('ABC123456DEF', 'A');
assert ($encodedA === 'ËABC123456DEFLÎ');

// Only encode using Type B.
$encodedB = Code128Encoder::encode('AcC123456DeF', 'B');
assert ($encodedB === 'ÌAcC123456DeFSÎ');

// Only encode using Type C.
$encodedC = Code128Encoder::encode('123456', 'C');
assert ($encodedC === 'Í,BXLÎ');

Use it together with the Libre Barcode 128 font to show a barcode on a webpage:

<?php

require __DIR__ . '/../vendor/autoload.php';

use Hbgl\Barcode\Code128Encoder;

$content = 'ABC123456DEF';
$encoded = Code128Encoder::encode($content);

?>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
        <title>Code 128</title>
        <link href="https://fonts.googleapis.com/css?family=Libre+Barcode+128&display=swap" rel="stylesheet">
        <style>
            body {
                text-align: center;
            }
            .code128 {
                padding: 3rem 1.5rem 0 1.5rem;
                font-family: "Libre Barcode 128";
                font-size: 3rem;
                transform: scaleY(1.5);
            }
        </style>
    </head>
    <body>
        <div class="code128"><?= htmlspecialchars($encoded) ?></div>
        <div><?= htmlspecialchars($content) ?></div>
    </body>
</html>

Result:

Barcode Result

PHP 7.x

Support for PHP 7.x ended with version 0.2.7.

License

This library is licensed under the MIT license.

统计信息

  • 总下载量: 52.63k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 未知

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固