PHPackages                             kekos/gs1 - 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. kekos/gs1

ActiveLibrary

kekos/gs1
=========

GS1 parser and generator for PHP

v1.0.3(9y ago)155.4k↓47.4%2MITPHPPHP &gt;= 5.3.0

Since May 22Pushed 9y ago1 watchersCompare

[ Source](https://github.com/Kekos/gs1-php)[ Packagist](https://packagist.org/packages/kekos/gs1)[ Docs](https://github.com/Kekos/gs1-php)[ RSS](/packages/kekos-gs1/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (5)Used By (0)

GS1 parser and generator for PHP
================================

[](#gs1-parser-and-generator-for-php)

Encodes and decodes GTIN numbers (EAN-8 and EAN-13) with support for products having variable weight and price.

Install
-------

[](#install)

You can install this package via [Composer](http://getcomposer.org/):

```
composer require kekos/gs1

```

Documentation
-------------

[](#documentation)

### Locales

[](#locales)

Each member country of [GS1](http://www.gs1.org/) have their own specification for products with variable weight and price, magazines and coupons. This is handled by this library by defining encoding rules in "locales".

Currently only the `Sweden` locale is implemented.

### Generate GTIN

[](#generate-gtin)

Start by creating an entity:

```
$entity = new \Gs1\Entity\WeightProduct($sku, $weight);
$entity = new \Gs1\Entity\PriceProduct($sku, $price);
$entity = new \Gs1\Entity\Publication($sku, $price);
$entity = new \Gs1\Entity\Coupon($id, $discount);
```

Use `GtinFactory` class by specifying which locale to use:

```
$code = \Gs1\GtinFactory::get('Sweden', $entity);
echo $code;
```

### Parse GTIN

[](#parse-gtin)

Create a GTIN entity:

```
$gtin = new \Gs1\Gtin\Gtin13($code);
$gtin = new \Gs1\Gtin\Gtin8($code);
```

Use `EntityFactory` class by specifying which locale to use:

```
$entity = \Gs1\EntityFactory::get('Sweden', $gtin);
if ($entity instanceof \Gs1\Entity\WeightProduct) {
  echo 'Weight: ' . $entity->getWeight();
}
```

### Product entity

[](#product-entity)

```
$product = new \Gs1\Entity\Product($sku, $company_prefix);
$product->getSku();
$product->setSku($sku);
$product->getCompanyPrefix();
$product->setCompanyPrefix($company_prefix);
```

### Weight product entity

[](#weight-product-entity)

```
$product = new \Gs1\Entity\WeightProduct($sku, $weight);
$product->getSku();
$product->setSku($sku);
$product->getWeight();
$product->setWeight($weight);
```

### Price product entity

[](#price-product-entity)

```
$product = new \Gs1\Entity\PriceProduct($sku, $price);
$product->getSku();
$product->setSku($sku);
$product->getPrice();
$product->setPrice($price);
```

### Coupon entity

[](#coupon-entity)

```
$coupon = new \Gs1\Entity\Coupon($id, $value);
$coupon->getId();
$coupon->setId($id);
$coupon->getValue();
$coupon->setValue($value);
```

### Publication entity

[](#publication-entity)

```
$publication = new \Gs1\Entity\Publication($sku, $price);
$publication->getSku();
$publication->setSku($sku);
$publication->getPrice();
$publication->setPrice($price);
```

### GTIN-13 entity (EAN-13) and GTIN-8 entity (EAN-8)

[](#gtin-13-entity-ean-13-and-gtin-8-entity-ean-8)

When setting the code you don't have to specify the checksum (digit 8 or 13). The `Gtin` classes will add the checksum automatically if needed.

```
$gtin = new \Gs1\Gtin\Gtin8($code);
// ...or
$gtin = new \Gs1\Gtin\Gtin13($code);

$gtin->getCode();
$gtin->setCode($code);
$gtin->isValid(); // true or false
$gtin->getChecksum();
$gtin->__toString(); // magic method
```

Bugs and improvements
---------------------

[](#bugs-and-improvements)

Report bugs in GitHub issues or feel free to make a pull request :-)

License
-------

[](#license)

MIT

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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.

###  Release Activity

Cadence

Every ~13 days

Total

4

Last Release

3599d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d95792c940b68df0577eaf918c0529b60f5b831a9a0bc093e306c581bc52c660?d=identicon)[Kekos](/maintainers/Kekos)

---

Top Contributors

[![Kekos](https://avatars.githubusercontent.com/u/914782?v=4)](https://github.com/Kekos "Kekos (5 commits)")

---

Tags

barcodeeangtinEAN 8EAN 13gs1

### Embed Badge

![Health badge](/badges/kekos-gs1/health.svg)

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

###  Alternatives

[picqer/php-barcode-generator

An easy to use, non-bloated, barcode generator in PHP. Creates SVG, PNG, JPG and HTML images from the most used 1D barcode standards.

1.8k25.5M85](/packages/picqer-php-barcode-generator)[tecnickcom/tc-lib-barcode

PHP library to generate linear and bidimensional barcodes

2957.1M28](/packages/tecnickcom-tc-lib-barcode)[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[intervention/validation

Additional validation rules for the Laravel framework

6826.7M8](/packages/intervention-validation)[ronanguilloux/isocodes

PHP library - Validators for standards from ISO, International Finance, Public Administrations, GS1, Book and Music Industries, Phone numbers &amp; Zipcodes for many countries

8013.3M23](/packages/ronanguilloux-isocodes)[mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

3148.6k1](/packages/mvdnbrk-gtin)

PHPackages © 2026

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