spatie/laravel-feed
Generate RSS, Atom, and JSON feeds for your Laravel app with minimal code. Install, register Route::feeds(), configure your feed items, and serve standards-compliant feeds from your application quickly and easily.
Install the package via composer require spatie/laravel-feed, then register feed routes with Route::feeds() in routes/web.php (optionally specifying a URL prefix like 'feeds' for /feeds/rss). Publish the config with php artisan feed:install, which creates config/feed.php—the central place to define feed configurations. Start with a simple example: implement the Feedable interface on a model (e.g., NewsItem) and define toFeedItem() to return a FeedItem instance. Configure the feed in config/feed.php by setting items (e.g., 'App\NewsItem@getFeedItems'), url, title, format (rss/atom/json), and image. Finally, include feed links in your HTML <head> via @include('feed::links') or the <x-feed-links /> Blade component for auto-discovery.
Feedable on Eloquent models and define toFeedItem(); ensure getFeedItems() is a static method returning a collection/array of models, arrays, or FeedItem instances.config/feed.php (e.g., 'news', 'blog') with different URLs, formats, and views—ideal for separating public news, internal updates, or API-based feeds (e.g., /news/rss vs /blog/atom).feed::atom/rss/json view by specifying a view key (e.g., 'view' => 'feeds.news') in the feed config, enabling branding or format tweaks (e.g., adding site logo, custom metadata).getFeedItems() using config like 'items' => ['App\NewsItem', 'getFeedItems', 'category' => 'tech'].Cache::remember('feed', 3600, fn => $items)) or integrate with Laravel’s cache within getFeedItems() for high-traffic sites.'items' => ['App\Http\Controllers\NewsController', 'feed'], where the controller method returns an array/collection.Route::feeds() before catch-all routes (e.g., Route::get('/{slug}')) in routes/web.php to avoid 404s; failing to do so is a common cause of silent failures (see changelog v1.0.2).updated in FeedItem uses a \Carbon\Carbon instance or RFC3339-compliant string (e.g., now()->toRfc3339String()); mismatched formats cause validation errors in some feed readers (fixed in v3.1.0+).summary() for plain text, and description() (if supported by your view) for HTML. Special characters and tags are allowed in summary (v1.0.9+), but avoid raw HTML in title—Spatie auto-wraps titles in CDATA (v1.0.10+).type and contentType keys in config (e.g., 'type' => 'application/rss+xml') are auto-detected, but explicitly set them if serving non-standard MIME types (e.g., JSON feeds).php artisan route:list | grep feed to verify routes. Inspect raw feed output via curl http://your-app.local/feed to catch XML/JSON validation issues early.FeedItem factory behavior by publishing views (php artisan vendor:publish --tag=feed-views) and extending Blade templates. For advanced customization, extend the Feed class or swap views at runtime with Feed::useView().Feed::clearCache() in model events). Avoid caching dynamic per-user data—feeds should be public.How can I help you explore Laravel packages today?