Yet another simple RSS writer library for PHP 5.4 or later.

1.6.0 2017-07-13 10:47 UTC

This package is auto-updated.

Last update: 2024-06-06 07:54:34 UTC


\Suin\RSSWriter is yet another simple RSS writer library for PHP 5.4 or later. This component is Licensed under MIT license.

This library can also be used to publish Podcasts.

Latest Stable Version Total Downloads Daily Downloads License Build Status Codacy Badge

Quick demo

$feed = new Feed();

$channel = new Channel();
    ->title('Channel Title')
    ->description('Channel Description')
    ->copyright('Copyright 2012, Foo Bar')
    ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->pubsubhubbub('', '') // This is optional. Specify PubSubHubbub discovery if you want.

// Blog item
$item = new Item();
    ->title('Blog Entry Title')
    ->description('<div>Blog body</div>')
    ->contentEncoded('<div>Blog body</div>')
    ->author('John Smith')
    ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->guid('', true)
    ->preferCdata(true) // By this, title and description become CDATA wrapped HTML.

// Podcast item
$item = new Item();
    ->title('Some Podcast Entry')
    ->description('<div>Podcast body</div>')
    ->enclosure('', 4889, 'audio/mpeg')

echo $feed; // or echo $feed->render();


<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="" xmlns:atom="" version="2.0">
    <title>Channel Title</title>
    <description>Channel Description</description>
    <copyright>Copyright 2012, Foo Bar</copyright>
    <pubDate>Tue, 21 Aug 2012 10:50:37 +0000</pubDate>
    <lastBuildDate>Tue, 21 Aug 2012 10:50:37 +0000</lastBuildDate>
    <atom:link rel="self" href="" type="application/rss+xml"/>
    <atom:link rel="hub" href=""/>
      <title><![CDATA[Blog Entry Title]]></title>
      <description><![CDATA[<div>Blog body</div>]]></description>
      <content:encoded><![CDATA[<div>Blog body</div>]]></content:encoded>
      <pubDate>Tue, 21 Aug 2012 10:50:37 +0000</pubDate>
      <author>John Smith</author>
      <title>Some Podcast Entry</title>
      <description>&lt;div&gt;Podcast body&lt;/div&gt;</description>
      <enclosure url="" type="audio/mpeg" length="4889"/>


Easy installation

You can install directly via Composer:

$ composer require suin/php-rss-writer

Manual installation

Add the following code to your composer.json file:

	"require": {
		"suin/php-rss-writer": ">=1.0"

...and run composer to install it:

$ composer install

Finally, include vendor/autoload.php in your product:

require_once 'vendor/autoload.php';

How to use

The examples directory contains usage examples for RSSWriter.

If you want to know APIs, please see FeedInterface, ChannelInterface and ItemInterface.

How to Test

$ vendor/bin/phpunit

Test through PHP 5.4 ~ PHP 7.0

$ docker-compose up


MIT license