1. Build an RSS 2.0 Feed with CodeIgniter

In this tutorial, we will build a RSS 2.0 Feed with the PHP framework CodeIgniter. After this tutorial, you will be able to build a feed for any custom website in no time at all.

2. Building an RSS Feed in Code Igniter

Actually, it was pretty straight forward, but I thought I’d take a few moments to outline step by step how I did it. Most of the inspiration (and a lot of blatant stealing) is taken from this post about RSS on the CodeIgniter forums. Please note, that this requires that you load the URL helper… which I autoload, but could just as easily be included in the contoller (thanks Attos). I start out by creating a controller named “feed”.

3. RSSParser at CI Wiki

I have created this page to document the RSSParser library I have put together. I wanted to add RSS items and couldn’t find anything to achieve this and so have put this together for anyone else that would like it.

Because the class is loading an externally hosted file performance van very wildly so I have added some simple caching into the class. The class is only on its first revision so there may well be bugs within it, if you find any please let me know and I will be happy to look into them.

4. Generate RSS 2.0 Feeds with CodeIgniter

I made rss named controller, so I would access my feeds at address that looks like: “example.com/rss”. If you want to know more about RSS 2.0 then you should read RSS 2.0 Specification. In our controller we need to load two libraries: xml helper and database library for Active Record. Now we should have nice setup and lets get ready to fill our index function with code.

5. Parsing RSS in Codeigniter with Simplepie

Here’s how to parse an RSS feed using Simplepie in Codeigniter. First you need to download the codeigniter Simplepie library form here. Once downloaded unzip the file and extract Simplepie.php. Place that file in your library folder.

Leave a Reply

Your email address will not be published. Required fields are marked *