PHPackages                             phpsoftbox/barcode - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpsoftbox/barcode

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpsoftbox/barcode
==================

Barcode and QR generation component for the PhpSoftBox framework

03PHP

Since Apr 11Pushed 1mo agoCompare

[ Source](https://github.com/phpsoftbox/barcode)[ Packagist](https://packagist.org/packages/phpsoftbox/barcode)[ RSS](/packages/phpsoftbox-barcode/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

PhpSoftBox Barcode
==================

[](#phpsoftbox-barcode)

Компонент генерации 1D/2D кодов для PhpSoftBox.

Что поддерживается
------------------

[](#что-поддерживается)

- EAN-13 (встроенные SVG/PNG генераторы);
- QR (встроенный генератор, форматы SVG/PNG);
- DataMatrix (встроенный генератор, форматы SVG/PNG);
- роутинг генерации через цепочку `BarcodeGeneratorChain`.

Текущие ограничения первой итерации:

- QR: уровни коррекции `M` и `H`, версии до `10`;
- DataMatrix: ECC200 single-region символы (от `10x10` до `26x26`).

Базовое использование
---------------------

[](#базовое-использование)

```
use PhpSoftBox\Barcode\BarcodeGeneratorChain;
use PhpSoftBox\Barcode\BarcodeOptions;
use PhpSoftBox\Barcode\BarcodeOutputFormat;
use PhpSoftBox\Barcode\BarcodeType;
use PhpSoftBox\Barcode\Generator\DataMatrixGenerator;
use PhpSoftBox\Barcode\Generator\Ean13PngGenerator;
use PhpSoftBox\Barcode\Generator\Ean13SvgGenerator;
use PhpSoftBox\Barcode\Generator\QrGenerator;
use PhpSoftBox\Barcode\QrErrorCorrectionLevel;
use PhpSoftBox\Barcode\QrLogoOptions;

$generator = new BarcodeGeneratorChain([
    new Ean13SvgGenerator(),
    new Ean13PngGenerator(),
    new QrGenerator(),
    new DataMatrixGenerator(),
]);

$ean = $generator->generate(
    data: '460123456789',
    type: BarcodeType::Ean13, // вернет PNG
    options: new BarcodeOptions(format: BarcodeOutputFormat::Png),
);

$eanSvg = $generator->generate(
    data: '460123456789',
    type: BarcodeType::Ean13, // вернет SVG
    options: new BarcodeOptions(format: BarcodeOutputFormat::Svg),
);

$qr = $generator->generate(
    data: 'P1-R1-C1',
    type: BarcodeType::Qr, // QR с логотипом в центре
    options: new BarcodeOptions(
        format: BarcodeOutputFormat::Svg,
        height: 256,
        qrErrorCorrection: QrErrorCorrectionLevel::H,
        qrLogo: new QrLogoOptions(
            path: __DIR__ . '/logo.png',
            sizeRatio: 0.18,
            padding: 6,
            backgroundColor: '#F3F4F6',
            borderColor: '#111827',
            borderWidth: 2,
            cornerRadius: 10,
        ),
    ),
);

$dm = $generator->generate(
    data: 'DM-460123456789',
    type: BarcodeType::DataMatrix,
    options: new BarcodeOptions(format: BarcodeOutputFormat::Svg, height: 256),
);
```

EAN-13
------

[](#ean-13)

`Ean13::normalize()`:

- принимает 12 цифр и автоматически рассчитывает контрольную цифру;
- принимает 13 цифр и проверяет корректность контрольной цифры;
- бросает исключение при некорректном формате/чексумме.

QR с логотипом
--------------

[](#qr-с-логотипом)

- при `qrLogo` генератор автоматически использует уровень коррекции `H`;
- `QrLogoOptions` поддерживает настройку размера/паддинга и стиля зоны под логотип: `backgroundColor`, `borderColor`, `borderWidth`, `cornerRadius`.

Тестовые артефакты
------------------

[](#тестовые-артефакты)

- перед запуском PHPUnit папка `local/tests/barcode` очищается автоматически;
- генерационные тесты сохраняют SVG/PNG артефакты в `local/tests/barcode`;
- при необходимости сохранение артефактов можно отключить: `BARCODE_TEST_SAVE_ARTIFACTS=0 vendor/bin/phpunit`.

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance58

Moderate activity, may be stable

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity11

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/0279d150240c97d210034878b0467462246dc14d29b5618157ff6a8be49a50e3?d=identicon)[inspector-who](/maintainers/inspector-who)

---

Top Contributors

[![inspector-who](https://avatars.githubusercontent.com/u/6973963?v=4)](https://github.com/inspector-who "inspector-who (1 commits)")

### Embed Badge

![Health badge](/badges/phpsoftbox-barcode/health.svg)

```
[![Health](https://phpackages.com/badges/phpsoftbox-barcode/health.svg)](https://phpackages.com/packages/phpsoftbox-barcode)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
