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);
}
}

Recent Courses on Laravel Daily

Laravel 13 Starter Kit Teams and Customizations

10 lessons
33 min

Roles and Permissions in Laravel 13

14 lessons
57 min

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read