1. Go to this page and download the library: Download ribal/onix 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/ */
use Ribal\Onix\CodeList\CodeList1;
use Ribal\Onix\CodeList\CodeList149;
use Ribal\Onix\CodeList\CodeList15;
use Ribal\Onix\CodeList\CodeList150;
use Ribal\Onix\CodeList\CodeList2;
use Ribal\Onix\CodeList\CodeList5;
use Ribal\Onix\Date;
use Ribal\Onix\Message\Header\Header;
use Ribal\Onix\Message\Header\Sender;
use Ribal\Onix\Message\Message;
use Ribal\Onix\Parser;
use Ribal\Onix\Product\DescriptiveDetail;
use Ribal\Onix\Product\Product;
use Ribal\Onix\Product\ProductIdentifier;
use Ribal\Onix\Product\TitleDetail;
use Ribal\Onix\Product\TitleElement;
$message = new Message();
$sender = new Sender();
$sender->setSenderName('Example Publishing Ltd.');
$header = new Header();
$header->setSender($sender);
$header->setSentDateTime(new Date(new \DateTime()));
$message->setHeader($header);
$product = new Product();
$product->setRecordReference('com.example.9781234567897');
$product->setNotificationType(CodeList1::resolve('03'));
$identifier = new ProductIdentifier();
$identifier->setProductIDType(CodeList5::resolve('15')); // ISBN-13
$identifier->setIDValue('9781234567897');
$product->addProductIdentifier($identifier);
$descriptiveDetail = new DescriptiveDetail();
$descriptiveDetail->setProductComposition(CodeList2::resolve('00'));
$descriptiveDetail->setProductForm(CodeList150::resolve('BC')); // Paperback
$titleElement = new TitleElement();
$titleElement->setTitleElementLevel(CodeList149::resolve('01'));
$titleElement->setTitleText('An Example Title');
$titleDetail = new TitleDetail();
$titleDetail->setTitleType(CodeList15::resolve('01'));
$titleDetail->addTitleElement($titleElement);
$descriptiveDetail->addTitleDetail($titleDetail);
$product->setDescriptiveDetail($descriptiveDetail);
$message->addProduct($product);
$parser = new Parser();
$xml = $parser->generate($message, 'reference', '3.1');
use Ribal\Onix\CodeList\CodeList198;
use Ribal\Onix\CodeList\CodeList91;
use Ribal\Onix\Product\ProductContact;
$contact = new ProductContact();
$contact->setProductContactRole(CodeList198::resolve('10')); // Product safety contact
$contact->setProductContactName('Example Publishing Ltd.');
$contact->setEmailAddress('[email protected]');
$contact->setStreetAddress('Example Street 1');
$contact->setLocationName('Berlin');
$contact->setPostalCode('10115');
$contact->setCountryCode(CodeList91::resolve('DE'));
$publishingDetail->addProductContact($contact);
$resource = new \Ribal\Onix\Product\SupportingResource();
$resource->setResourceContentType(CodeList158::resolve('01')); // Front cover
$resource->setContentAudience(CodeList154::resolve('00'));
$resource->setResourceMode(CodeList159::resolve('03')); // Image
$resource->setResourceLink('https://example.com/cover.jpg');
// Either get the code list object and read its code and/or label
$type = $product->getNotificationType();
$code = $type->getCode(); // "03"
$value = $type->getValue(); // "Notification confirmed on publication"
// or directly get the label as string
$value = (string) $product->getNotificationType();