In this tutorial, I demonstrate how to generate a feed using Php that can be displayed from a website in multiple formats, including Atom 1.0 and RSS 2.0. I will be using functionality from the Php FeedWriter class library to generate the feed, which is available for free at http://phpFeedWriter.webmasterhub.net/.
I have broken up the process below into separate components, and provided additional information to help you learn each aspect of creating the feed using Php. A download of the completed script written in this tutorial is also provided if required.
Summary
- Prepare your feed script/page - Instantiate a (Php) FeedWriter Class Object
- Add additional (Channel) data to the feed
- Add Items to the Feed
- Get the specified feed output format
- (Optional) Set the “Content” element of each feed item as type “HTML”
- Output the Feed XML
- (Optional) Writing to a file / Caching Feed Content