2. Using Fast Feed

2.1. Factory way

FastFeed provide a Factory, to easy instanciate FastFeed.


use FastFeed\Factory;

$fastFeed = Factory::create();

2.2. Manual way

Maybe you want more control about the FastFeed is create then continue reading

2.2.1. Instance Guzzle

FastFeed used Guzzle to perform HTTP requests, this makes for a very flexible system.


use Guzzle\Http\Client;

// Client
$client = new Client();

Here you have guzzle documentation.

2.2.2. Instance Monolog

FastFeed needs a log system, that implements the PSR-3 to manage log. We recommend you use monolog


use Monolog\Logger;
use Monolog\Handler\StreamHandler;

// Monolog
$logger = new Logger('name');
$logger->pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING));

Here you have the monolog documentation.

2.2.3. Put it together

Now you can create FastFeed instance.


use FastFeed\FastFeed;
use FastFeed\Parser\RSSParser;

$fastFeed = new FastFeed($client, $logger);
$fastFeed->pushParser(new RSSParser());

If you want to know more about parsers.

2.3. Add feeds

FastFeed manage two concepts, the feeds represent a resource that have content that you want retrieve. The channels are a feed’s group.


$fastFeed->addFeed('default', 'http://desarrolla2.com/feed');

2.4. Enjoy

You only need retrieve the information and use it as you want.


$items = $fastFeed->fetch('default');
foreach ($items as $item) {
    echo '<h1>' . $item->getName() . '</h1>' . PHP_EOL;

2.5. Continue reading


comments powered by Disqus