Skip to main content
Back to packages
978 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

Next.js Basics for Laravel Developers

11 lessons
58 min

Roles and Permissions in Laravel 13

14 lessons
57 min

Queues in Laravel 13

18 lessons
1 h 12 min read

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.