PHPackages                             mykemeynell/laravel-syndication - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. mykemeynell/laravel-syndication

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mykemeynell/laravel-syndication
===============================

RSS and Atom feeds for laravel

v1.2.1(3y ago)0604MITPHP

Since Dec 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/mykemeynell/laravel-syndication)[ Packagist](https://packagist.org/packages/mykemeynell/laravel-syndication)[ RSS](/packages/mykemeynell-laravel-syndication/feed)WikiDiscussions v1.2 Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

Laravel Syndication
===================

[](#laravel-syndication)

A super simple RSS and Atom feed package for Laravel. Can generate either RSS, Atom or both - for specified models.

- [Installation](#installation)
    - [With auto-discover](#with-auto-discovery)
    - [Without auto-discover](#without-auto-discovery)
- [Publishing the configuration](#publish-the-configuration)
- [Config](#config)
    - [Feeds](#feeds)
    - [Routing](#routing)
    - [Encoding](#encoding)
    - [Caching](#caching)
- [Usage](#usage)
    - [Creating a new feed](#creating-a-new-feed)
    - [Configuring a `Feed`](#configuring-a-feed)
        - [Feed Types](#feed-types)
    - [Configuring the feed model](#configuring-the-feed-model)
        - [Fully configured model example](#fully-configured-model-example)
    - [Outputting meta tags to view](#outputting-meta-tags-to-view)

Installation
------------

[](#installation)

```
composer require mykemeynell/laravel-syndication

```

### With auto-discovery

[](#with-auto-discovery)

The service provider has already been registered, so you can continue to the next step.

### Without auto-discovery

[](#without-auto-discovery)

Add the `LaravelSyndicationServiceProvider` to your `config/app.php` file.

```
    'providers' => [
        // ...
        LaravelSyndication\LaravelSyndicationServiceProvider::class,
        // ...
    ],
```

Publish the configuration
-------------------------

[](#publish-the-configuration)

This will create a new configuration file under `config/syndication.php`.

```
php artisan vendor:publish --tag=laravel-syndication

```

Config
======

[](#config)

Feeds
=====

[](#feeds)

```
/*
 * Feeds that can be used for syndication are defined here. This should be
 * done using a key-value pair -- where the key is the identifier
 * of the feed, adn the value is the feed object.
 *
 * For example:
 *  'posts' => App\Feeds\Posts::class
 */
'feeds' => [],
```

Routing
-------

[](#routing)

```
'routing' => [
    /*
     *  Sets the prefix of any generated feeds.
     * default is 'feeds'.
     */
    'prefix' => 'feeds',

    /*
     * If you'd like to serve your feeds from a separate domain
     * or subdomain - you can specify the domain here.
     */
    'domain' => null,
],
```

Encoding
--------

[](#encoding)

```
/*
 * Encoding for the generated files, it will default to utf8 if there is no
 * other value specified -- so if you'd like a simpler config
 * file, then feel free to remove this key.
 */
'encoding' => 'utf-8',
```

Caching
-------

[](#caching)

Sets the default caching value for all feeds. If set to false, nothing will be cached and no values current cached will be read.

```
'cache_feeds' => true,
```

Specify the cache store to use. Using `null` will default to the default cache store.

```
'cache_store' => null,
```

How long (in minutes) the cache is valid for.

```
'cache_ttl' => 1440,
```

If you would like to specify different TTLs for different feeds, then you can do this here. It should be keyed using the same keys defined in the `feeds` key array, appended with the type of feed, for example; `'podcasts.atom'` or `'podcasts.rss'`

To disable caching for specific feeds, set the value to `false`.

To disable caching for all feeds except those specified, set `cache_feeds` to false, and specify a value greater than `0` in `caching`.

```
'caching' => [
    'posts.atom' => 10080
],
```

Usage
=====

[](#usage)

Creating a new feed
-------------------

[](#creating-a-new-feed)

### Use artisan to create a new feed class.

[](#use-artisan-to-create-a-new-feed-class)

For example, if you wanted to create a feed for podcasts;

```
php artisan make:feed Postcasts

```

This will output a feed class object at `app/Feeds/Postcasts.php`.

### Add the feed class to `config/syndication.php`

[](#add-the-feed-class-to-configsyndicationphp)

Under the `feeds` key, add the FQN of the feed you just created.

```
'feeds' => [
    // ...
    'podcasts' => App\Feeds\Postcasts::class
    // ...
],
```

### Configuring a `Feed`

[](#configuring-a-feed)

#### Feed Types

[](#feed-types)

Use the following base classes to determine the kind of feeds that can be generated, and the methods that are available in the `setUp()` method.

**Base Class****RSS Only**`LaravelSyndication\Feeds\RssFeed::class`**RSS &amp; Atom**`LaravelSyndication\Feeds\RssAndAtomFeed::class`**Atom Only**`LaravelSyndication\Feeds\AtomFeed::class`#### Configuration methods

[](#configuration-methods)

All configuration on a feed object is done in the `setUp()` method.

For example:

```
namespace App\Feeds;

class Podcast extends RssAndAtomFeed
{
  public function setUp(): void
  {
    $this->model(\App\Models\Podcast::class)
      ->title("Awesome Podcast")
      ->description("An amazing podcast.")
      ->url(url('/podcasts'))
      ->language("en")
      ->updated($this->lastCachedAt());
  }
}
```

### Configuring the feed model

[](#configuring-the-feed-model)

Once you have created your feed object and specified the model and filter you would like to use when generating feed contents. You will need to add the `LaravelSyndication\Contracts\Models\IsSyndicationItem` interface to your model.

The `IsSyndicationItem` interface specifies a single method `toFeedItem` that is expected to return an instance of `LaravelSyndication\Feeds\FeedItem`.

For example:

```
function toFeedItem(): FeedItem
{
    return (new FeedItem())
        ->title($this->title)
        ->description($this->excerpt)
        ->url(route('postcast.listen', $this->slug));
}
```

You can also create the feed item using an associative array if you prefer, by passing it as an argument to the FeedItem construct. For example:

```
function toFeedItem(): FeedItem
{
    return new FeedItem([
        'title' => $this->title,
        'description' => $this->excerpt,
        'url' => route('podcast.listen', $this->slug)
    ]);
}
```

Additional options are also available when creating your FeedItem:

```
/**
 * Will specify the URL for comments.
 */
FeedItem::comments(string $commentsUrl)
```

```
/**
 * The email address of the feed item author.
 *
 * Can be specified as an array or Collection of \LaravelSyndication\Feeds\Structure\Atom\Person objects,
 * or a single LaravelSyndication\Feeds\Structure\Atom\Person object.
 */
FeedItem::author(array|Collection|Person $author)
```

```
/**
 * Includes a media file to be included with an item.
 *
 * The enclosure method accepts either 2, or 4 arguments, depending on what data you pass:
 *
 * @param string      $url      The public URL to the enclosure item.
 * @param int|null    $length   Filesize in bytes -- if omitted, then an attempt to read the file is made.
 * @param string|null $type     MIME type of the enclosure -- required if $filename is null.
 * @param string|null $filename Optional, can be left blank if $length and $type are specified.
 */
FeedItem::enclosure(string $url, ?string $type = null, ?string $filename = null, ?int $length = null)
```

```
/**
 * Specifies the value of the  tag on an .
 *
 * If a Uuid instance of string is passed, then it is prepended with 'urn:uuid:'
 * before being output. Otherwise, it is output as it is passed.
 *
 * This method can be omitted, and the value of the url() method will be used.
 *
 * Atom only.
 */
FeedItem::id(int|\Ramsey\Uuid\Uuid|string $idUri)
```

```
/**
 * Specifies the  tag of the .
 *
 * Atom only.
 */
FeedItem::content(null|string|\LaravelSyndication\Feeds\Structure\Atom\Content $content)
```

```
/**
 * When specified, the value of FeedItem::content() is ignored and content is
 * generated from a passed enclosure instead.
 *
 * Note: If used, this should be called after FeedItem::enclosure().
 *
 * Atom only.
 */
FeedItem::contentFromEnclosure()
```

```
/**
 * Sets the  tag on an entry.
 *
 * Atom only.
 */
FeedItem::updated(\Carbon\Carbon $updated)
```

```
/**
 * Atom: Sets the  tag on an entry.
 * RSS: Sets the  tag on an item.
 */
FeedItem::published(\Carbon\Carbon $published)
```

```
/**
 * Sets the  attribute on an entry.
 *
 * Atom only.
 */
FeedItem::copyright(string $copyright)
```

```
/**
 * Sets the value of the  tag on an .
 *
 * Atom only.
 */
FeedItem::category(string $term)
```

```
/**
 * Used to specify the  tag of an , for example if the
 * is a copy, or references another source.
 */
FeedItem::source(\LaravelSyndication\Feeds\Structure\Items\Atom\Source $source)
```

Below is an example of how you might configure a source:

```
FeedItem::source(
  new Source(
    id: route('podcast.listen', $this->getKey()),
    title: $this->title,
    updated: $this->updated_at,
    author: new Person(name: $this->author->name, email: $this->author->email)
  )
)
```

### Fully configured model example

[](#fully-configured-model-example)

```
function toFeedItem(): FeedItem
{
  return (new FeedItem())
    // Using the ID method assumes that the model is making use of UUID
    // primary keys.
    ->id($this->getKey())

    // These are the common fields between Atom and RSS fields.
    ->title($this->seo_title ?? $this->title)
    ->description($this->meta_description ?? $this->excerpt ?? $this->title)
    ->url(route('podcast.listen', $this->getKey()))

    // The URL for comments.
    // This is only used in RSS feeds and is not output as part of Atom.
    ->comments(route('podcast.single', $this->slug . '#comments'))

    // Atom feeds will output specific  tags, whereas RSS
    // will output a comma-separated list of email addresses.
    ->author([
        new Person(name: $this->authorId->name, email: $this->authorId->email),
        new Person(name: $this->authorId->name, email: $this->authorId->email),
    ])

    // Specifies the data to be used in the  tag in an RSS feed.
    // can be used in conjunction with FeedItem::contentFromEnclosure() to
    // create the appropriate  tag on an Atom feed.
    ->enclosure(
        url: route('post.read', $this->slug),
        filename: storage_path('podcasts/' . $this->podcast_file_location)
    )

    // ... Like this.
    ->contentFromEnclosure()

    // Sets the value of the  tag. Only used as part of Atom feeds.
    ->updated($this->updated_at)

    // Sets the value of the  or  tag in Atom and RSS
    // feeds respectively.
    ->published($this->published_at)

    // Copyright information relating specifically to an entry on an Atom feed
    //  item.
    ->copyright("Copyright 2022 Acme Inc.")

    // Copyright information relating specifically to an entry on an Atom feed
    //  item.
    ->category("Tech")

    // Builds the value of the  tag.
    // Statically typed here -- but you get the idea of what it does.
    ->source(
        new Source(
            id: 'https://example.com/some-unqiue-url-that-wont-change',
            title: 'The Title of The Source',
            updated: now(),
            author: new Person(name: "John Doe", email: "john@example.com", uri: "https://example.com/authors/john")
        )
    );
}
```

---

Outputting meta tags to view
----------------------------

[](#outputting-meta-tags-to-view)

Add the following code to your blade views to output meta tags for registered feeds.

These use the alias of the facade at: `LaravelSyndication\Facades\Syndicate`

To meta tags for all registered feeds:

```

{!! LaravelSyndication::meta() !!}

```

To output meta tags for specific feeds:

```

{!! LaravelSyndication::meta('podcasts', 'blog') !!}

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~23 days

Total

4

Last Release

1183d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/494de8188ad97403b72e40e385235a74ef6331aa2710b3727193f646189af9fc?d=identicon)[mykemeynell](/maintainers/mykemeynell)

---

Top Contributors

[![mykemeynell](https://avatars.githubusercontent.com/u/1590190?v=4)](https://github.com/mykemeynell "mykemeynell (22 commits)")

---

Tags

atomatom-feedcachedlaravelmodelrssrss-feed

### Embed Badge

![Health badge](/badges/mykemeynell-laravel-syndication/health.svg)

```
[![Health](https://phpackages.com/badges/mykemeynell-laravel-syndication/health.svg)](https://phpackages.com/packages/mykemeynell-laravel-syndication)
```

###  Alternatives

[jcbrand/converse.js

Browser based XMPP instant messaging client

3.2k156.6k](/packages/jcbrand-conversejs)[pastuhov/yii2-yml-catalog

YML (Yandex Market Language) generator.

2116.7k](/packages/pastuhov-yii2-yml-catalog)[flagbit/table-attribute-bundle

The Flagbit Table Attribute Bundle for Akeneo PIM gives you the possibility to enrich your product with multi-dimensional data presentation in the form of tables, allowing you maximum flexibility within the PIM.

2310.4k](/packages/flagbit-table-attribute-bundle)[mirazmac/bangla-string

A wannabe all-in-all Bangla String Manupulation Library!

103.0k](/packages/mirazmac-bangla-string)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
