2017 © Pedro Peláez
 

library gs1

GS1 parser and generator for PHP

image

kekos/gs1

GS1 parser and generator for PHP

  • Thursday, June 30, 2016
  • by Kekos
  • Repository
  • 1 Watchers
  • 7 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 64 % Grown

The README.md

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., (*1)

Install

You can install this package via Composer:, (*2)

composer require kekos/gs1

Documentation

Locales

Each member country of GS1 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"., (*3)

Currently only the Sweden locale is implemented., (*4)

Generate GTIN

Start by creating an entity:, (*5)

$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:, (*6)

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

Parse GTIN

Create a GTIN entity:, (*7)

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

Use EntityFactory class by specifying which locale to use:, (*8)

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

Product entity

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

Weight product entity

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

Price product entity

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

Coupon entity

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

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)

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., (*9)

$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

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

License

MIT, (*11)

The Versions

30/06 2016

dev-master

9999999-dev https://github.com/Kekos/gs1-php

GS1 parser and generator for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

barcode ean gs1 ean-8 ean-13 gtin

30/06 2016

v1.0.3

1.0.3.0 https://github.com/Kekos/gs1-php

GS1 parser and generator for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

barcode ean gs1 ean-8 ean-13 gtin

12/06 2016

v1.0.2

1.0.2.0 https://github.com/Kekos/gs1-php

GS1 parser and generator for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

barcode ean gs1 ean-8 ean-13 gtin

04/06 2016

v1.0.1

1.0.1.0 https://github.com/Kekos/gs1-php

GS1 parser and generator for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

barcode ean gs1 ean-8 ean-13 gtin

22/05 2016

v1.0.0

1.0.0.0 https://github.com/Kekos/gs1-php

GS1 parser and generator for PHP

  Sources   Download

MIT

The Requires

  • php >= 5.3.0

 

barcode ean gs1 ean-8 ean-13 gtin