SimplePie is a PHP library that can fetch, cache, parse, and normalize RSS and Atom feeds. It allows you to display the newest articles from websites with RSS or Atom feeds on your own site. This is a great way to add new, fresh, and relevant information to your site. This guide shows how you can set it up for your own web site.

SimplePie Setup

I want to set up SimplePie in a subdirectory of my document root /var/www/web1/web called simplepie so I create it as follows (together with a cache directory that SimplePie needs for caching feeds):

mkdir /var/www/web1/web/simplepie
mkdir /var/www/web1/web/simplepie/cache

Then I change the ownership of the simplepie directory and its subdirectories and make the cache directory world-writable:

cd /var/www/web1/web/
chown -R web1_falko:web1 simplepie/
chmod 777 simplepie/cache/

Next I download SimplePie to the /var/www/web1 directory (make sure you grab the latest version from http://simplepie.org/downloads/?download):

cd /var/www/web1
wget http://simplepie.org/downloads/simplepie_1.1.1.zip

To unpack it, we need the unzip tool. If it’s not installed, install it now (on Debian/Ubuntu, you can do it as follows:

apt-get install unzip

)

Now let’s unzip SimplePie and move the contents of the package to our /var/www/web1/web/simplepie directory:

unzip simplepie_1.1.1.zip
cd SimplePie\ 1.1.1/
mv simplepie.inc /var/www/web1/web/simplepie/
mv compatibility_test/ /var/www/web1/web/simplepie/
mv demo/ /var/www/web1/web/simplepie/
mv idn/ /var/www/web1/web/simplepie/
chown -R web1_falko:web1 /var/www/web1/web/simplepie/
chmod 777 /var/www/web1/web/simplepie/demo/cache

The compatibility_test directory contains a test to check if your server fulfills all requirements – basically what we’ve done with the phpinfo() function already in chapter 1.

The demo directory contains a working SimplePie demo (it uses its own cache directory therefore we must make this world-writable as well).

The only file we actually need to run SimplePie is simplepie.inc – that’s the SimplePie library.

Let’s remove the SimplePie directory and zip file afterwards to clean up our system:

cd ..
rm -fr SimplePie\ 1.1.1/
rm -f simplepie_1.1.1.zip

SimplePie is now set up and ready to be used.

Post By Editor (2,827 Posts)

Website: →

Connect