PHP code example of findologic / libflexport

1. Go to this page and download the library: Download findologic/libflexport 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/ */

    

findologic / libflexport example snippets




use FINDOLOGIC\Export\Exporter;

$exporter = Exporter::create(ExporterType::XML);

$item = $exporter->createItem('123');

$item->addName('Test');
$item->addUrl('http://example.org/test.html');
$item->addPrice(13.37);
// Alternative long form:
// $name = new Name();
// $name->setValue('Test');
// $item->setName($name);
// $url = new Url();
// $url->setValue('http://example.org/test.html');
// $item->setUrl($url);
// $price = new Price();
// $price->setValue(13.37);
// $item->setPrice($price);

$xmlOutput = $exporter->serializeItems([$item], 0, 1, 1);



use FINDOLOGIC\Export\Exporter;

$exporter = Exporter::create(ExporterType::CSV);

$item = $exporter->createItem('123');

$item->addPrice(13.37);
$item->addName('Test');
$item->addUrl('http://example.org/test.html');
// Alternative long form:
// $name = new Name();
// $name->setValue('Test');
// $item->setName($name);
// $url = new Url();
// $url->setValue('http://example.org/test.html');
// $item->setUrl($url);
// $price = new Price();
// $price->setValue(13.37);
// $item->setPrice($price);

// Date is mandatory for CSV.
$item->addDateAdded(new \DateTime());

$csvOutput = $exporter->serializeItems([$item], 0, 1, 1);