augmentedlogic / feedibus
RSS writer library with support for most of the RSS specification, including Media RSS and GeoRSS
v0.9.1
2026-07-27 11:34 UTC
Requires
- php: >=8.4
README
This originally started as a a fork of suin/php-rss-writer (in July 2026), but has become a project of its own. The aim to make it a more complete library including Channel Image, Media RSS, GeoRSS support and PHP 8 compatibility.
Changelog
v0.9
- support for GeoRSS (at least the basics)
- item->link() does the same as item->url()
v0.8.1
- added tag for Item
- added Media RSS media:hash tag
v0.7
- documentation fixes
v0.6
- support for MediaRSS (most of it anyway, there are endless options)
v0.5
- namespace change
- now available on packagist
v0.2
- added ChannelImage class
- some preliminary typing for php 8
Installation
composer require augmentedlogic/feedibus
Usage
use com\augmentedlogic\feedibus\Channel; use com\augmentedlogic\feedibus\ChannelImage; use com\augmentedlogic\feedibus\Feed; use com\augmentedlogic\feedibus\Item; use com\augmentedlogic\feedibus\MediaItem; $feed = new Feed(); $channelImage = new ChannelImage(); $channelImage->url("https://example.com/icon.png") ->link("https://example.com/icon.png") ->title("Acme Ltd Logo"); $channel = new Channel(); $channel ->title('Channel Title') ->description('Channel Description') ->url('http://blog.example.com') ->feedUrl('http://blog.example.com/rss') ->language('en-US') ->image($channelImage) ->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')) ->ttl(60) ->pubsubhubbub('http://example.com/feed.xml', 'http://pubsubhubbub.appspot.com') // This is optional. Specify PubSubHubbub discovery if you want. ->appendTo($feed); // Blog item $item = new Item(); $item ->title('Blog Entry Title') ->description('<div>Blog body</div>') ->contentEncoded('<div>Blog body</div>') ->url('http://blog.example.com/2012/08/21/blog-entry/') ->author('John Smith') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->guid('http://blog.example.com/2012/08/21/blog-entry/', true) ->preferCdata(true) // By this, title and description become CDATA wrapped HTML. ->source('http://blog.example.com/') ->appendTo($channel); // Media RSS item $mediaitem = new MediaItem(); $mediaitem ->url("https://www.example.com") ->title("Oh my wonderful RSS", "plain") ->filesize(5020281) ->filetype("audio/mpeg") ->medium("audio") ->width(1920) ->height(1080) ->bitrate(2500) ->framerate(25) ->samplingrate(44.1) ->channels(2) ->lang("en") ->thumbnail("https://example.com/image.jpg") ->thumbnailWidth(900) ->thumbnailHeight(600) ->expression("full") ->description("a wonderful song") ->keywords(array("rock", "blues")) ->playerUrl("https://example.com") ->playerWidth(1920) ->playerHeight(1080); ->hash('bf1ab2d7290a1bed086fdab56f268f48', 'md5'); $item = new Item(); $item ->title('Some Media RSS Entry') ->description('<div>Podcast body</div>') ->url('http://podcast.example.com/2012/08/21/podcast-entry/') ->media($mediaitem) ->appendTo($channel); // Podcast item $item = new Item(); $item ->title('Some Podcast Entry') ->description('<div>Podcast body</div>') ->url('http://podcast.example.com/2012/08/21/podcast-entry/') ->enclosure('http://podcast.example.com/2012/08/21/podcast.mp3', 4889, 'audio/mpeg') ->appendTo($channel); echo $feed; // or echo $feed->render();
Output:
<?xml version="1.0" encoding="UTF-8"?> <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Channel Title</title> <link>http://blog.example.com</link> <description>Channel Description</description> <language>en-US</language> <image> <url>https://example.com/icon.png</url> <title>Acme Ltd Logo</title> <link>https://example.com/icon.png</link> </image> <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> <ttl>60</ttl> <atom:link rel="self" href="http://example.com/feed.xml" type="application/rss+xml"/> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/> <item> <title><![CDATA[Blog Entry Title]]></title> <link>http://blog.example.com/2012/08/21/blog-entry/</link> <description><![CDATA[<div>Blog body</div>]]></description> <content:encoded><![CDATA[<div>Blog body</div>]]></content:encoded> <guid>http://blog.example.com/2012/08/21/blog-entry/</guid> <pubDate>Tue, 21 Aug 2012 10:50:37 +0000</pubDate> <author>John Smith</author> <source>http://blog.example.com/</source> </item> <item xmlns:media="http://search.yahoo.com/mrss"> <title>Some Media RSS Entry</title> <link>http://podcast.example.com/2012/08/21/podcast-entry/</link> <description><div>Podcast body</div></description> <media:content xmlns:media="http://search.yahoo.com/mrss" url="https://www.example.com" fileSize="5020281" type="audio/mpeg" medium="audio" expression="full" width="1920" height="1080" bitrate="2500" framerate="25" samplingrate="44.1" channels="2" lang="en"/> <media:title xmlns:media="http://search.yahoo.com/mrss" type="plain">Oh my wonderful RSS</media:title> <media:description xmlns:media="http://search.yahoo.com/mrss">a wonderful song</media:description> <media:thumbnail xmlns:media="http://search.yahoo.com/mrss" url="https://example.com/image.jpg" width="900" height="600"/> <media:player xmlns:media="http://search.yahoo.com/mrss" url="https://example.com" width="1920" height="1080"/> <media:keywords xmlns:media="http://search.yahoo.com/mrss">rock,blues</media:keywords> <media:hash xmlns:media="http://search.yahoo.com/mrss" algo="md5">bf1ab2d7290a1bed086fdab56f268f48</media:hash> </item> <item> <title>Some Podcast Entry</title> <link>http://podcast.example.com/2012/08/21/podcast-entry/</link> <description><div>Podcast body</div></description> <enclosure url="http://podcast.example.com/2012/08/21/podcast.mp3" type="audio/mpeg" length="4889"/> </item> </channel> </rss>
GeoRSS example
use com\augmentedlogic\feedibus\Channel; use com\augmentedlogic\feedibus\ChannelImage; use com\augmentedlogic\feedibus\GeoRSSFeed; use com\augmentedlogic\feedibus\Item; use com\augmentedlogic\feedibus\MediaItem; $feed = new GeoRSSFeed(); $channel = new Channel(); $channel->title('Channel Title') ->description('Channel Description') ->url('http://blog.example.com') ->appendTo($feed); $item = new Item(); $item ->title('Some Geo Entry') ->description('This is London') ->url('http://example.com/london') ->point(51.5074, -0.1278) // point is lat, lon ->appendTo($channel); echo $feed->render();
License
MIT license