Very light weight PHP API encapsulating entire RSS-2 specification, the worldwide standard at this moment for generating RSS feeds.
API only requires PHP7.1+ and comes with a class for each RSS tag, all belonging to Lucinda\RSS namespace, each implementing Tag interface. Following are factually mandatory:
Class | Description |
---|---|
RSS | Encapsulates rss tag, the grand holder of your RSS feed |
Channel | Encapsulates channel tag, child of rss, containing your RSS feed description |
Item | Encapsulates item tag, child of channel, containing an article in your RSS feed |
Simple example:
$channel = new \Lucinda\RSS\Channel("Lucinda Framework", "https://www.lucinda-framework.com", "Current headlines from Lucinda Framework");
$channel->addItem(new \Lucinda\RSS\Item("STDOUT MVC API", "STDOUT MVC API was upgraded to a new version"));
$channel->addItem(new \Lucinda\RSS\Item("STDERR MVC API", "STDERR MVC API was upgraded to a new version"));
$rss = new \Lucinda\RSS\RSS($channel);
echo $rss; // displays RSS feed
API enjoys 100% unit test coverage for its classes and methods, reproductible in console by running:
composer update
php test.php
Class RSS encapsulates rss tag logic via following void returning methods:
Method | Arguments | Description |
---|---|---|
__construct | Channel $channel | Constructs feed based on mandatory RSS channel |
addNamespace | string $name string $url |
Adds a RSS namespace able to add custom functionality to feed |
To understand more how namespaces can be used to add non-standard tags to feed, visit this guide!
Class Channel encapsulates channel tag logic via following void returning methods:
Method | Arguments | Description |
---|---|---|
__construct | string $title string $link string $description |
Sets values of required sub-tags: title, link, description [1] |
addItem | Item $item | Sets value of sub-tag item |
setLanguage | string $language | Sets value of sub-tag language |
setCopyright | string $copyright | Sets value of sub-tag copyright |
setManagingEditor | string $email | Sets value of sub-tag managingEditor |
setWebMaster | string $email | Sets value of sub-tag webMaster |
setPubDate | int $unixTime | Sets value of sub-tag pubDate by corresponding unix time |
setLastBuildDate | int $unixTime | Sets value of sub-tag lastBuildDate by corresponding unix time |
setCategory | string $category | Sets value of sub-tag category |
setGenerator | string $generator | Sets value of sub-tag generator |
setDocs | string $url | Sets value of sub-tag docs |
setCloud | Cloud $cloud | Sets value of sub-tag cloud |
setTtl | int $number | Sets value of sub-tag ttl |
setImage | Image $image | Sets value of sub-tag image |
setTextInput | Input $textInput | Sets value of sub-tag textInput |
setSkipHours | SkipHours $skipHours | Sets value of sub-tag skipHours |
setSkipDays | SkipDays $skipDays | Sets value of sub-tag skipDays |
addCustomTag | Tag $tag | Adds custom non-standard sub-tag |
[1] Value of $description is automatically escaped using CDATA via Escape class, in order to make it possible to put HTML inside
Class Item encapsulates item tag logic via following void returning methods:
Method | Arguments | Specification |
---|---|---|
__construct | string $title string $description |
Sets values of required sub-tags: title, description [1] |
setLink | string $url | Sets value of sub-tag link |
setAuthor | string $email | Sets value of sub-tag author |
setCategories | string $category | Sets value of sub-tag categories |
setComments | string $url | Sets value of sub-tag comments |
setEnclosure | Enclosure $enclosure | Sets value of sub-tag enclosure |
setGuid | string $guid | Sets value of sub-tag guid |
setPubDate | int $unixTime | Sets value of sub-tag pubDate by corresponding unix time |
setSource | string $url | Sets value of sub-tag source |
addCustomTag | Tag $tag | Adds custom non-standard sub-tag |
[1] Value of $description is automatically escaped using CDATA via Escape class, in order to make it possible to put HTML inside
Interface Tag defines common ability of all RSS tags to be stringified via following method:
Method | Arguments | Returns |
---|---|---|
__toString | - | string |
Class Escape envelopes a value using CDATA via following method inherited from Tag:
Method | Arguments | Returns |
---|---|---|
__toString | - | string |