PHPackages                             kreativekorp/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. kreativekorp/barcode

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

kreativekorp/barcode
====================

Generate barcodes from a single PHP file.

2839.9k↑46.4%139[24 issues](https://github.com/kreativekorp/barcode/issues)[2 PRs](https://github.com/kreativekorp/barcode/pulls)HTML

Since Feb 22Pushed 3y ago18 watchersCompare

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

READMEChangelog (1)DependenciesVersions (1)Used By (0)

barcode.php
===========

[](#barcodephp)

### Generate barcodes from a single PHP file. MIT license.

[](#generate-barcodes-from-a-single-php-file-mit-license)

- Output to PNG, GIF, JPEG, or SVG.
- Generates UPC-A, UPC-E, EAN-13, EAN-8, Code 39, Code 93, Code 128, Codabar, ITF, QR Code, and Data Matrix.

### Use directly as a PHP script with GET or POST:

[](#use-directly-as-a-php-script-with-get-or-post)

```
barcode.php?f={format}&s={symbology}&d={data}&{options}

```

e.g.

```
barcode.php?f=png&s=upc-e&d=06543217
barcode.php?f=svg&s=qr&d=HELLO%20WORLD&sf=8&ms=r&md=0.8

```

**When using this method, you must escape non-alphanumeric characters with URL encoding, for example `%26` for `&` or `%2F` for `?`.**

### Or use as a library from another PHP script:

[](#or-use-as-a-library-from-another-php-script)

```
include 'barcode.php';

$generator = new barcode_generator();

/* Output directly to standard output. */
header("Content-Type: image/$format");
$generator->output_image($format, $symbology, $data, $options);

/* Create bitmap image and write to standard output. */
header('Content-Type: image/png');
$image = $generator->render_image($symbology, $data, $options);
imagepng($image);
imagedestroy($image);

/* Create bitmap image and write to file. */
$image = $generator->render_image($symbology, $data, $options);
imagepng($image, $filename);
imagedestroy($image);

/* Generate SVG markup and write to standard output. */
header('Content-Type: image/svg+xml');
$svg = $generator->render_svg($symbology, $data, $options);
echo $svg;

/* Generate SVG markup and write to file. */
$svg = $generator->render_svg($symbology, $data, $options);
file_put_contents($filename, $svg);

```

**When using this method, you must NOT use URL encoding.**

### Options:

[](#options)

`f` - Format. One of:

```
    png
    gif
    jpeg
    svg

```

`s` - Symbology (type of barcode). One of:

```
    upc-a          code-39         qr     dmtx
    upc-e          code-39-ascii   qr-l   dmtx-s
    ean-8          code-93         qr-m   dmtx-r
    ean-13         code-93-ascii   qr-q   gs1-dmtx
    ean-13-pad     code-128        qr-h   gs1-dmtx-s
    ean-13-nopad   codabar                gs1-dmtx-r
    ean-128        itf

```

`d` - Data. For UPC or EAN, use `*` for missing digit. For Codabar, use `ABCD` or `ENT*` for start and stop characters. For QR, encode in Shift-JIS for kanji mode.

`w` - Width of image. Overrides `sf` or `sx`.

`h` - Height of image. Overrides `sf` or `sy`.

`sf` - Scale factor. Default is 1 for linear barcodes or 4 for matrix barcodes.

`sx` - Horizontal scale factor. Overrides `sf`.

`sy` - Vertical scale factor. Overrides `sf`.

`p` - Padding. Default is 10 for linear barcodes or 0 for matrix barcodes.

`pv` - Top and bottom padding. Default is value of `p`.

`ph` - Left and right padding. Default is value of `p`.

`pt` - Top padding. Default is value of `pv`.

`pl` - Left padding. Default is value of `ph`.

`pr` - Right padding. Default is value of `ph`.

`pb` - Bottom padding. Default is value of `pv`.

`bc` - Background color in `#RRGGBB` format.

`cs` - Color of spaces in `#RRGGBB` format.

`cm` - Color of modules in `#RRGGBB` format.

`tc` - Text color in `#RRGGBB` format. Applies to linear barcodes only.

`tf` - Text font for SVG output. Default is monospace. Applies to linear barcodes only.

`ts` - Text size. For SVG output, this is in points and the default is 10. For PNG, GIF, or JPEG output, this is the GD library built-in font number from 1 to 5 and the default is 1. Applies to linear barcodes only.

`th` - Distance from text baseline to bottom of modules. Default is 10. Applies to linear barcodes only.

`ms` - Module shape. One of: `s` for square, `r` for round, or `x` for X-shaped. Default is `s`. Applies to matrix barcodes only.

`md` - Module density. A number between 0 and 1. Default is 1. Applies to matrix barcodes only.

`wq` - Width of quiet area units. Default is 1. Use 0 to suppress quiet area.

`wm` - Width of narrow modules and spaces. Default is 1.

`ww` - Width of wide modules and spaces. Applies to Code 39, Codabar, and ITF only. Default is 3.

`wn` - Width of narrow space between characters. Applies to Code 39 and Codabar only. Default is 1.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity48

Moderate usage in the ecosystem

Community21

Small or concentrated contributor base

Maturity23

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90% 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/b3cfa54a75562ce8d09c7718c05c5573f45cee8125e56e3c6a682aeb2141150b?d=identicon)[thisispiers](/maintainers/thisispiers)

---

Top Contributors

[![RebeccaRGB](https://avatars.githubusercontent.com/u/1642055?v=4)](https://github.com/RebeccaRGB "RebeccaRGB (9 commits)")[![cwchristerw](https://avatars.githubusercontent.com/u/13464896?v=4)](https://github.com/cwchristerw "cwchristerw (1 commits)")

---

Tags

barcodebarcode-generatorbarcodescodabarcode128code39code93datamatrixeanean13ean8linear-barcodesmatrix-barcodesphpqr-codeqrcodeqrcode-generatorupcupc-aupc-e

### Embed Badge

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

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

PHPackages © 2026

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