PHP code example of ayeo / gs1

1. Go to this page and download the library: Download ayeo/gs1 library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ayeo / gs1 example snippets


class MyCustomCompany implements CompanyInterface
{
    public function getGcp()
    {
       return new Model\Gcp('123456');
    }
    
    public function getName()
    {
       return "My Custom Name";
    }
    

    public function getLocation()
    {
        $location = new MyCustomLocation();
    } 
}

class MyCustomLocation implements LocationInterface
{
    public function getAddress()
    {
        $address = new Model\Address;
        $address->streetName = 'Secret Avenue';
        $address->buildingNumber = 10;
        $address->countryName = "England";
        $address->postcode = 'NG10 5GH';
    }

    public function getLocationNumber()
    {
        return '00';
    }
    
   
    public function getTelephoneNumber()
    {
        return '560 560 506';
    }
    
    
    public function getFaxNumber()
    {
        return '';
    }
    
    
    public function getWebsiteAddress()
    {
        return 'ayeo.pl';
    }
}


$content = new Model\Content;
$content->setName('test product');
$content->setBatchSymbol('abc12345');
$content->setGrossWeight(2);
$content->setGtin('1234512345123');
$content->setQuantity(120);
$content->setBestBefore(new DateTime);

$gs1 = new Gs1Facade($company);
$label = $gs1->buildLabel($content, $orderNumber = '000102', $logicticCounter = 232);