Oh Dear is the all-in-one monitoring tool for your entire website. We monitor uptime, SSL certificates, broken links, scheduled tasks and more. You'll get a notifications for us when something's wrong. All that paired with a developer friendly API and kick-ass documentation. O, and you'll also be able to create a public status page under a minute. Start monitoring using our free trial now.

A package to easily generate feeds in Laravel

Original – by Freek Van der Herten – 2 minute read

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.

Installation encompasses:

  • 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\News@getAll',
            /*
             * 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.

Stay up to date with all things Laravel, PHP, and JavaScript.

You can follow me on these platforms:

On all these platforms, regularly share programming tips, and what I myself have learned in ongoing projects.

Every month I send out a newsletter containing lots of interesting stuff for the modern PHP developer.

Expect quick tips & tricks, interesting tutorials, opinions and packages. Because I work with Laravel every day there is an emphasis on that framework.

Rest assured that I will only use your email address to send you the newsletter and will not use it for any other purposes.

Comments

What are your thoughts on "A package to easily generate feeds in Laravel"?

Comments powered by Laravel Comments
Want to join the conversation? Log in or create an account to post a comment.