Skip to content

Repository files navigation

GS1-128 (EAN128) Decoder

Basic GS1-128 (EAN128) decoder in PHP.

Installation

composer require nextgen-tech/gs1-decoder

Run Tests

# run PHPUnit tests
vendor/bin/phpunit
# run PHPStan analyse
vendor/bin/phpstan analyse

To run all tests automatically on several platforms you can use act, which mimics GitHub Actions locally:

$ act -P ubuntu-latest=shivammathur/node:latest

Usage

useNGT\Barcode\GS1Decoder\Decoder;
$decoder = newDecoder($delimiter = '[FNC1]');
$barcode = $decoder->decode('0195012345678903422616[FNC1]3103000123');
print_r($barcode->toArray());
Array
(
[value] => 0195012345678903422616[FNC1]3103000123
[delimiter] => [FNC1]
[identifiers] => Array
(
[01] => Array
(
[code] => 01
[title] => GTIN
[name] => Global Trade Item Number
[length] => 14
[content] => 95012345678903
[raw_content] => 95012345678903
)
[422] => Array
(
[code] => 422
[title] => ORIGIN
[name] => Country of origin of a trade item
[length] => 3
[content] => 616
[raw_content] => 616
)
[310] => Array
(
[code] => 310
[title] => NET WEIGHT (kg)
[name] => Net weight, kilograms
[length] => 6
[content] => 0.123
[raw_content] => 000123
[decimals] => 3
)
)
)

List of implemented identifiers

IdentifierTitleDescription
00SSCCSerial Shipping Container Code
01GTINGlobal Trade Item Number (GTIN)
02CONTENTGTIN of contained trade items
10BATCH/LOTBatch or lot number
11PROD DATEProduction date
12DUE DATEDue date
13PACK DATEPackaging date
15BEST BEFOREBest before date
16SELL BYSell by date
17USE BYExpiration date
20VARIANTInternal product variant
21SERIALSerial number
91INTERNALCompany internal information
422ORIGINCountry of origin of a trade item
3100-3105NET WEIGHT (kg)Net weight, kilograms
3920-3929PRICEApplicable amount payable, single monetary area (variable measure trade item)
8005PRICE PER UNITPrice per unit of measure
8008PROD TIMEDate and time of production

The list of all GS1 Application Identifiers can be found here

About

Basic GS1-128 (EAN128) decoder in PHP

Topics

Resources

Stars

10 stars

Watchers

1 watching

Forks

Releases

Contributors

Languages