Skip to main content
Back to packages
980 GitHub stars

spatie/laravel-feed

View on GitHub

Description

Easily generate RSS feeds

This package provides an easy way to generate a feed for your Laravel application. Supported formats are RSS, Atom, and JSON.

Usage

Imagine you have a model named NewsItem that contains records that you want to have displayed in the feed.

First you must implement the Feedable interface on that model. Feedable expects one method: toFeedItem, which should return a FeedItem instance.

// app/NewsItem.php
 
use Illuminate\Database\Eloquent\Model;
use Spatie\Feed\Feedable;
use Spatie\Feed\FeedItem;
 
class NewsItem extends Model implements Feedable
{
public function toFeedItem(): FeedItem
{
return FeedItem::create()
->id($this->id)
->title($this->title)
->summary($this->summary)
->updated($this->updated_at)
->link($this->link)
->authorName($this->author)
->authorEmail($this->authorEmail);
}
}