1. Go to this page and download the library: Download tomcan/feed-importer 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/ */
tomcan / feed-importer example snippets
// define the feed
$feed = new FeedDefinition(['url' => 'https://raw.githubusercontent.com/TomCan/feed-importer/refs/heads/main/samples/toms-favorite-names.csv']);
// instantiate processor without callback
$processor = new FeedProcessorCsv($feed);
// instantiate downloader
$downloader = new FeedDownloader($feed, $processor);
// use ->generate function
foreach ($downloader->generate() as $row) {
echo 'Got a record: '.str_replace(PHP_EOL, ' ', print_r($row, true)).PHP_EOL;
}
// profit
// define the feed
$feed = new FeedDefinition(['url' => 'https://raw.githubusercontent.com/TomCan/feed-importer/refs/heads/main/samples/toms-favorite-names.csv']);
// write your callback
$callback = function (array $row) {
echo 'Got a record: '.str_replace(PHP_EOL, ' ', print_r($row, true)).PHP_EOL;
};
// instantiate processor with callback
$processor = new FeedProcessorCsv($feed, $callback);
// instantiate downloader
$downloader = new FeedDownloader($feed, $processor);
// use ->download function
$downloader->download();
// profit
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.