imnotjames/syndicator

Parse and serialize syndicated feeds.


Keywords
xml, atom, rss, feeds, podcast
License
MIT

Documentation

Syndicator

Basic library to parse and compose syndication feeds.

Build Status Coverage Status

Currently Supported Standards:

  • RSS XML 2.0

For any others feel free to open an issue.

Installation

The easiest method of installation is with composer, on packagist.

Usage

Composition of Syndication feeds:

use imnotjames\Syndicator\Article;
use imnotjames\Syndicator\Feed;
use imnotjames\Syndicator\Logo;
use imnotjames\Syndicator\Serializers\RSSXML;

$feed = new Feed(
    'My Rad Feed',
    'This feed is the coolest feed out there.',
    'https://github.com/imnotjames/syndicator'
);

$feed->setLogo(new Logo('http://i.imgur.com/haED2k7.jpg'));

$feed->setGenerator('Coolness Generator v95000');

$feed->setCacheTimeToLive(42);

$article = new Article();

$article->setTitle('How to be cool');
$article->setDescription('Step 1.  Be cool.  Step 2.  Don\'t be not cool.');
$article->setURI('http://example.com/blog/how-to-be-cool');

$feed->addArticle($article);

$serializer = new RSSXML();

$xml = $serializer->serialize($feed);

And decomposition:

use imnotjames\Syndicator\Parsers\RSSXML;

$parser = new RSSXML();

$feed = $parser->parse(file_get_contents('awesome_feed.xml'));

printf("Title: %s\n\n", $feed->getTitle());

echo "Articles:\n";

foreach ($feed as $article) {
    printf("\tTitle: %s", $article->getTitle());
    echo "\n";
}

License

MIT License