/ laravel

Using SimplePie with Laravel

RSS feeds are everywhere. There are dozen of ways to process and show them, but SimplePie has definitely become the go-to way of easily managing feeds within your PHP application.


SimplePie is available as a Packagist package, so installing it is as simple as running this command in your Terminal:

$ require: "simplepie/simplepie": "dev-master"

The SimplePie class is now available in your project and you can easily make use of it.


SimplePie is well documented and there are plenty of examples around. Caching is something I had some trouble setting up, but by using the storage_path() function that Laravel provides on the Helpers package:

$feed = new SimplePie();

The feed is now initialized and you can pass it along to your views. Blade makes it extremely easy to use the feed object:

@foreach($feed->get_items(0,3) as $item)
    {{ $item->get_title() }}
    {{ $item->get_description() }}

And that's it! It's really that simple to start using SimplePie on your Laravel webapp.

Rui Gomes

Rui Gomes

Web Developer, Internet Marketing enthusiast and Student@FEUP. That pretty much sums it up.

Read More