Pharaonic
Loading...

Installation

RSS

# Why RSS?

RSS is a package that helps to generate RSS feed so it can be easier than write the whole XML.

# Installation

Install the latest version using Composer.

1composer require pharaonic/php-rss

# Example

This is an example of generating a channel with multiple items.

1$feed = (new RSS())
2 ->setTitle('PAGE TITLE')
3 ->setDescription('PAGE DESCRIPTION')
4 ->setLink('https://pharaonic.io');
5 
6$feed->setItem(
7 (new RSSItem)
8 ->setTitle('Slugify')
9 ->setDescription('Simplest Slugify for PHP to convert string into a slug')
10 ->setLink('https://pharaonic.io/packages/php/slugify')
11);
12 
13$feed->setItem(
14 (new RSSItem)
15 ->setTitle('Hijri')
16 ->setDescription('PHP Package that helps to convert Gregorian to Hijri date')
17 ->setLink('https://pharaonic.io/packages/php/hijri')
18);
19 
20echo $feed->render();

The result is going to be like this :

1<?xml version="1.0" encoding="UTF-8"?>
2<rss version="2.0">
3 <channel>
4 <generator>Pharaonic RSS Generator</generator>
5 <title>PAGE TITLE</title>
6 <description>PAGE DESCRIPTION</description>
7 <link>https://pharaonic.io</link>
8 <pubDate>Tue, 08 Mar 2022 04:38:49 +0000</pubDate>
9 <item>
10 <title>Slugify</title>
11 <description>Simplest Slugify for PHP to convert string into a slug</description>
12 <link>https://pharaonic.io/packages/php/slugify</link>
13 </item>
14 <item>
15 <title>Hijri</title>
16 <description>PHP Package that helps to convert Gregorian to Hijri date</description>
17 <link>https://pharaonic.io/packages/php/hijri</link>
18 </item>
19 </channel>
20</rss>