You have to create the channel but there are some required fields.
1use Pharaonic\RSS\RSS; 2 3$feed = (new RSS()) 4 ->setTitle('PAGE TITLE') // REQUIRED 5 ->setDescription('PAGE DESCRIPTION') // REQUIRED 6 ->setLink('https://pharaonic.io') // REQUIRED 7 8 ->setImage('https://pharaonic.io/x.jpg') // OPTIONAL 9 ->setLanguage('en') // OPTIONAL10 ->setCopyright('Copyright 2021, Pharaonic') // OPTIONAL11 ->setPublished('Fri, 02 Oct 2020 00:00:01 +0200') // OPTIONAL12 ->setUpdated('Tue, 15 Jun 2021 15:00:00 +0200'); // OPTIONAL
You can create the item of feed but there are some required fields.
1use Pharaonic\RSS\RSSItem; 2 3$item = (new RSSItem) 4 ->setTitle('Slugify') // REQUIRED 5 ->setDescription('Simplest Slugify for PHP to convert string into a slug') // REQUIRED 6 ->setLink('https://pharaonic.io/packages/php/slugify') // REQUIRED 7 8 ->setGUID('https://pharaonic.io/package/1-general-php/7-hijri') // OPTIONAL 9 ->setCategory('Packages')->setCategory('PHP') // OPTIONAL10 ->setAuthor('someone@example.com (Someone Name)') // OPTIONAL11 ->setPublished('Tue, 25 May 2021 16:14:00 +0200'); // OPTIONAL
Append the Item to the Channel, you can use one of this 2 ways.
1// WAY 12$feed->setItem($item);3 4// WAY 25$item->appendToChannel($feed);
Generate the whole feed and you can use one of this 2 ways but you should display the feed with Content-Type=text/xml.
1// WAY 12echo $feed->render();3 4// WAY 25echo $feed;