This package helps you generate Rss channels.


Primary repository:
Github repository:


The best way to install it is via Composer. Just add nexendrie/rss to your dependencies.


Create new instance of \Nexendrie\Rss\Generator, set its properties title and description. Then add data source for channel's items. It has to return \Nexendrie\Rss\Collection which is a collection of \Nexendrie\Rss\RssChannelItem.


use Nexendrie\Rss\Generator,

$generator = new Generator;
$generator->title = "Nexendrie RSS";
$generator->link = "";
$generator->description = "News for package nexendrie/rss";
$generator->dataSource = function() use($generator) {
  $items = new Collection;
  $items[] = new RssChannelItem("Item 1", "Item 1 description", "", date($generator->dateTimeFormat));
  return $items;
$result = $generator->generate();

Method generate returns plain text that can showed with echo.

Advanced usage

It is possible to change time format for the channel. Just use:

$generator->dateTimeFormat = "your preferred format";

By default, only first 150 characters of items' description is printed. You can change the length limit like this:

$generator->shortenDescription = 150;

or completely disable it by setting the property to 0.

You can also change lastBuildDate for channel by setting property lastBuildDate of the Generator. It accepts callback that returns integer which is interpreted as timestamp. Default value is current time.

Nette applications

The package contains extension for Nette DI container which adds the generator. It allows you to set maximal length of items' description. Example (with default values):

    rss: Nexendrie\Rss\Bridges\NetteDI\RssExtension
    shortenDescription: 150
    dateTimeFormat: "Y-m-d H:i:s"

If do not need to do anything with the result after generating, you can you method response instead of generate to get a response to send from your presenter:

$response = $this->generator->response();