Yesterday our newest package laravel-feed was released. It makes generating RSS feeds in Laravel very easy. It’s very opinionated to fit the needs of our projects, but I believe lots of other developers will find it useful too. There’s almost no coding involved to create some feeds.
- registering the service provider (you’ve probably done this a gazillion times by now)
- publishing a config file
- calling a route macro in your routes file to register the view routes
- adding a partial in the head section of your template to display links to the feeds
After you’ve done that adding feeds to your site is a breeze. You’ll only need to add some values to the configuration file. Here’s an example:
return [ 'feeds' => [ [ /* * Here you can specify which class and method will return * the items that should appear in the feed. */ 'items' => '\App\[email protected]', /* * The feed will be available on this url. */ 'url' => '/feed', ... ], ], ];
After that you’re done. The package will convert all models that are returned by the
getAll()-function of the
\App\Model-class to feed items. The feed items will be displayed on the
/feed url. On all pages a link to that feed will appear in the head section.
Want to know more about the package? Then head over to GitHub to read the readme and view some code. If you like it, maybe one of our other Laravel packages can be of some use to you as well.