lamoda / gs1-barcode-parser
GS1 Barcode parser and validator compatible with official GS1 documentation
Installs: 46 952
Dependents: 1
Suggesters: 0
Security: 0
Stars: 20
Watchers: 16
Forks: 9
Open Issues: 1
Requires
- php: ^7.1 | ^8.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15
- phpunit/phpunit: ^7.5.20 | ^8.2 | ^9.0
README
Installation
Composer
composer require lamoda/gs1-barcode-parser
Description
This library provides parsing of GS1 Barcodes according to GS1 General specification and GS1 DataMatrix Guideline.
Library also provides general purpose validator for barcode's content.
Usage
Parser
<?php $config = new \Lamoda\GS1Parser\Parser\ParserConfig(); $parser = new \Lamoda\GS1Parser\Parser\Parser($config); $value = ']d201034531200000111719112510ABCD1234'; $barcode = $parser->parse($value); // $barcode is an object of Barcode class
Validator
<?php $parserConfig = new \Lamoda\GS1Parser\Parser\ParserConfig(); $parser = new \Lamoda\GS1Parser\Parser\Parser($parserConfig); $validatorConfig = new \Lamoda\GS1Parser\Validator\ValidatorConfig(); $validator = new \Lamoda\GS1Parser\Validator\Validator($parser, $validatorConfig); $value = ']d201034531200000111719112510ABCD1234'; $resolution = $validator->validate($value); if ($resolution->isValid()) { // ... } else { var_dump($resolution->getErrors()); }