PHP code example of widefocus / feed-csv-writer

1. Go to this page and download the library: Download widefocus/feed-csv-writer 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/ */

    

widefocus / feed-csv-writer example snippets




use WideFocus\Feed\CsvWriter\CsvWriterFactory;
use WideFocus\Feed\CsvWriter\LeagueCsv\LeagueCsvWriterFactory;
use League\Flysystem\MountManager;
use League\Flysystem\Filesystem;
use League\Flysystem\Adapter\Local;

$mountManager = new MountManager(
    ['local' => new Filesystem(new Local('/tmp'))]
);

$writerFactory = new CsvWriterFactory(
    new LeagueCsvWriterFactory(),
    $mountManager
);



use WideFocus\Parameters\ParameterBag;
use WideFocus\Feed\Writer\WriterField;

$parameters = new ParameterBag([
    'destination' => 'local://my-feed.csv',
    '



use ArrayIterator;
use ArrayObject;

$items = new ArrayIterator(
    [
        new ArrayObject(['foo' => 'FooValue', 'bar' => 'BarValue']),
        new ArrayObject(['foo' => 'AnotherFooValue', 'bar' => 'AnotherBarValue'])
    ]
);

$writer->write($items);