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

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

sglms/gs1-gtin
==============

Classes to create or validate GTIN (Global Trade Item Number) and GS1; includes barcode generation. Laravel 12 Service Provider.

2.0.4(2mo ago)2165↓78.9%1[1 PRs](https://github.com/SGLMS/gtin-gs1/pulls)MITPHPPHP &gt;=8.3CI passing

Since Aug 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/SGLMS/gtin-gs1)[ Packagist](https://packagist.org/packages/sglms/gs1-gtin)[ Docs](https://sglms.com)[ RSS](/packages/sglms-gs1-gtin/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (15)Versions (20)Used By (0)

GS1 / GTIN
==========

[](#gs1--gtin)

GS1-128 / GTIN (UPCA; EAN8; ITF14) creator and parser; including barcode generation.

In this version we have included Laravel Service Providers.

Installation
------------

[](#installation)

```
composer require sglms/gtin-gs1
```

Usage
-----

[](#usage)

### GTIN (GTIN-14)

[](#gtin-gtin-14)

Generate GTIN-14 (prefix + company number + item reference + check digit):

```
use Sglms\Gs1Gtin\Gtin;

$gtin = Gtin::create(9876543210);
// GTIN: 10098765432102

$gtin = Gtin::create(
    itemNumber: 98765,
    companyPrefix: '0123'
);
// GTIN: 10123000987656

$gtin = Gtin::create(
    itemNumber: 987654,
    companyPrefix: '123',
    type: 'GTIN-14',
    packagingLevel: 2
);
// GTIN: 21230009876549
```

#### Display (on-the-fly)

[](#display-on-the-fly)

```
// Display barcode (SVG)
echo $gtin->barcode();
```

[![barcode](resources/images/gtin.jpg "Generated barcode")](resources/images/gtin.jpg)

#### Save (with numbers) and display

[](#save-with-numbers-and-display)

```
// Save barcode
echo $gtin->saveBarcode('path/barcode');
echo "";
```

[![barcode](resources/images/gtin_numbers.jpg "Generated barcode")](resources/images/gtin_numbers.jpg)

For now, only JPG images are supported, but will add other standards as needed.

#### Validate

[](#validate)

```
Gtin::validate(11230000456781); # TRUE
```

### GTIN-12 (UPC-A)

[](#gtin-12-upc-a)

Generate GTIN-12 (company number + item reference + check digit):

```
use Sglms\Gs1Gtin\Gtin12;

$gtin = Gtin12::create(
    itemNumber: 123,
    companyPrefix: '45678',
);
// GTIN / UPC-A: 456780001230
```

```
// Save barcode
$gtin->saveBarcode('path/barcode');

// Save barcode with numbers
$gtin->saveWithNumber('../resources/images/gtin12_numbers');
echo "";
```

[![barcode](resources/images/gtin12_numbers.jpg "Generated barcode")](resources/images/gtin12_numbers.jpg)

### GTIN-8 (EAN-8)

[](#gtin-8-ean-8)

Generate GTIN-8 (company number + item reference + check digit):

```
use Sglms\Gs1Gtin\Gtin8;

$gtin = Gtin8::create(
    itemNumber: 123,
    companyPrefix: '4567'
);

echo $gtin;
// GTIN-8 / EAN-8: 45671234

// Save barcode
$gtin->barcode();

$gtin->saveBarcode('../resources/images/gtin8');
echo "";

// Save barcode with numbers
$gtin->saveWithNumber('../resources/images/gtin8_numbers');
echo "";
```

[![barcode](resources/images/gtin8_numbers.jpg "Generated barcode")](resources/images/gtin8_numbers.jpg)

GS1
---

[](#gs1)

```
use Sglms\Gs1Gtin\Gs1;

$gs1 = Gs1::parse('(01)10012345678902(10)ABC123(3201)000500(3302)000700(17)250630(21)SN123456(37)10(11)230101');
echo $gs1;
// GS1: (01)10012345678902(10)ABC123(3102)002268(3302)000700(11)230101(17)250630(21)SN123456(37)10

// Display (SVG)
echo $gs1->barcode(showNumbers:true);

// Or, you can save a JPG image with numbers
$gs1->saveBarcode('../resources/images/images/gs1', ['01','37', '21','3102','3302'], 80);
```

[![barcode](resources/images/gs1.jpg "Generated barcode")](resources/images/gs1.jpg)

```
object(Sglms\Gs1Gtin\Gs1)[4]
  public array 'data' =>
    array (size=8)
      '01' => string '00012345678905' (length=14)
      3302 => string '000700' (length=6)
      3102 => string '002268' (length=6)
      11 => string '230101' (length=6)
      17 => string '250630' (length=6)
      21 => string 'SN123456' (length=8)
      37 => int 10
      10 => string 'ABC123' (length=6)
  public ?string 'gs1' => string '(01)00012345678905(10)ABC123(3201)000500(3302)000700(17)250630(21)SN123456(37)10(11)230101' (length=90)
  public ?string 'sscc' => null
  public ?string 'gtin' => string '00012345678905' (length=14)
  public ?string 'content' => null
  public ?string 'netWeight' => string '002268' (length=6)
  public ?string 'grossWeight' => string '000700' (length=6)
  public ?string 'batch' => string 'ABC123' (length=6)
  public ?string 'serial' => string 'SN123456' (length=8)
  public ?string 'productionDate' => string '230101' (length=6)
  public ?string 'expirationDate' => string '250630' (length=6)
  public ?int 'pieces' => int 10

```

You can also create a GS1 instance verbously.

```
$gs1 = Gs1::create(
    gtin: '00012345678905',
    serial: 'ABC123',
    netWeightPounds: 1000,
    grossWeight:6000,
    pieces:10,
);
echo $gs1;
echo $gs1->barcode(
    codes: ['01','37', '21','3102','3302'],
    showNumbers:true
);
```

### Standards

[](#standards)

GS1 Identifiers can be found [here](https://www.databar-barcode.info/application-identifiers/). We use only a few, they are enumerated in `src/Gs1Codes.php`, you can add your own as needed.

```
enum Gs1Code: string
{
    case SSCC           = '00';
    case GTIN           = '01'; // n2+n14
    case Content        = '02'; // n2+n14
    case BatchNumber    = '10';
    case ProductionDate = '11'; // n2+n6
    case PaymentDate    = '12'; // n2+n6
    case BestBeforeDate = '15'; // n2+n6
    case ExpirationDate = '17'; // n2+n6
    case SerialNumber   = '21';
    case Units          = '37'; // n2+n..8
    case NetWeight      = '3102'; //n4+n6 (2 decimals)
    case GrossWeight    = '3302'; //n4+n6 (2 decimals)
}
```

Credits
=======

[](#credits)

Bar code generator: [picqer/php-barcode-generator](https://github.com/picqer/php-barcode-generator).

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance89

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity71

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 ~82 days

Recently: every ~47 days

Total

17

Last Release

87d ago

Major Versions

0.2 → 1.02022-08-30

1.2.4 → 2.02025-09-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13224306?v=4)[James](/maintainers/jaimercz)[@jaimercz](https://github.com/jaimercz)

---

Top Contributors

[![jaimercz](https://avatars.githubusercontent.com/u/13224306?v=4)](https://github.com/jaimercz "jaimercz (36 commits)")

---

Tags

barcodeean-8gs1-128gtingtin-14phpupc-alaravelgtings1sglms

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[blair2004/nexopos

The Free Modern Point Of Sale System build with Laravel, TailwindCSS and Vue.js.

1.2k2.4k](/packages/blair2004-nexopos)[stephenjude/filament-blog

Filament Blog Builder

20619.4k](/packages/stephenjude-filament-blog)[mvdnbrk/gtin

GTIN / EAN / UPC Validation for Laravel

3148.8k1](/packages/mvdnbrk-gtin)[datomatic/nova-detached-actions

A Laravel Nova tool to allow for placing actions in the Nova toolbar detached from the checkbox selection mechanism.

11273.0k](/packages/datomatic-nova-detached-actions)

PHPackages © 2026

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