Download the PHP package mykemeynell/laravel-syndication without Composer
On this page you can find all versions of the php package mykemeynell/laravel-syndication. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download mykemeynell/laravel-syndication
More information about mykemeynell/laravel-syndication
Files in mykemeynell/laravel-syndication
Package laravel-syndication
Short Description RSS and Atom feeds for laravel
License MIT
Informations about the package 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
- With auto-discover
- Without auto-discover
- Publishing the configuration
- Config
- Feeds
- Routing
- Encoding
- Caching
- Usage
- Creating a new feed
- Configuring a
Feed
- Feed Types
- Configuring the feed model
- Fully configured model example
- Outputting meta tags to view
Installation
With auto-discovery
The service provider has already been registered, so you can continue to the next step.
Without auto-discovery
Add the LaravelSyndicationServiceProvider
to your config/app.php
file.
Publish the configuration
This will create a new configuration file under config/syndication.php
.
Config
Feeds
Routing
Encoding
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.
Specify the cache store to use. Using null
will default to the default cache
store.
How long (in minutes) the cache is valid for.
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
.
Usage
Creating a new feed
Use artisan to create a new feed class.
For example, if you wanted to create a feed for podcasts;
This will output a feed class object at app/Feeds/Postcasts.php
.
Add the feed class to config/syndication.php
Under the feeds
key, add the FQN of the feed you just created.
Configuring a Feed
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 & Atom | LaravelSyndication\Feeds\RssAndAtomFeed::class |
Atom Only | LaravelSyndication\Feeds\AtomFeed::class |
Configuration methods
All configuration on a feed object is done in the setUp()
method.
For example:
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:
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:
Additional options are also available when creating your FeedItem:
Below is an example of how you might configure a source:
Fully configured model example
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:
To output meta tags for specific feeds: