In this tutorial, we'll go over how to create RSS feeds in Laravel 9 using the roumen/feed package. Therefore, to create an RSS feed, we are utilizing the roumen/feed package.

We may quickly deliver a fresh update of our websites using the RSS feed. such as newsletters and updates to new articles, etc.

Although Google Feedburner, Mailchimp, and Mailgun all offer RSS feed functionality, you can also create RSS feeds using Laravel.

Table of Contents

  1. Install Laravel
  2. Setting Database Configuration
  3. Create Table using migration
  4. Install roumen/feed Package
  5. Add providers and aliases
  6. Create Route
  7. Create a Model and Controller
  8. Run Our Laravel Application

Install Laravel

We're going to install Laravel 9, so first, open the terminal or command prompt and use it to navigate to the XAMPP htdocs folder directory. then execute the command below.

composer create-project --prefer-dist laravel/laravel laravel9_rss_feed

Setting Database Configuration

when Laravel has been fully installed. We must configure the database. We will now open the .env file and make the necessary changes to the database name, username, and password. Changes to a .env file can be seen below.


Create Table using migration

We must now start a migration. Consequently, we will use the command below to create a posts table migration.

php artisan make:migration create_posts_table --create=posts

following successful migration. The database/migrations/create posts table file needs to be modified as shown below.

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreatePostsTable extends Migration
     * Run the migrations.
     * @return void
    public function up()
        Schema::create('posts', function (Blueprint $table) { 
     * Reverse the migrations.
     * @return void
    public function down()

Once the above file has been modified, run the command below.

php artisan migrate

Install roumen/feed Package

Now, using the command below, we'll install the roumen/feed package.

composer require roumen/feed

Add providers and aliases

In the "config/app.php" section, we will add the providers and aliases listed below.

'providers' => [
'aliases' => [
 'Feed' => Roumen\Feed\Feed::class,

Create Route

In the "routes/web.php" file, add the following route code.

| Web Routes
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
Route::get('/', function () {
   // return view('welcome');	
Route::get('rss-feed' 'FeedController@rssFeed');

Create a Model and Controller

The commands listed below assist in creating the controller and model.

php artisan make:model Post
php artisan make:controller FeedController


namespace App;
use Illuminate\Database\Eloquent\Model;
class Post extends Model
 protected $fillable = [
        'title','slug', 'author','description','content'


namespace App\Http\Controllers;
use App;
use App\Post;
use Illuminate\Http\Request;
class FeedController extends Controller
     * Display a listing of the resource.
     * @return \Illuminate\Http\Response
    public function rssFeed(Request $request)
       /* create new feed */
	   $feed = App::make("feed");
	   /* Take out 15 posts from database to create feed */
	   $posts = Post::orderBy('created_at', 'desc')->take(15)->get();
	   /* Set feed's title, description, link, publish date and language */
	   $feed->title = 'Feedtitle';
	   $feed->description = 'Feed description';
	   $feed->logo = 'logo url';
	   $feed->link = url('feed');
	   $feed->pubdate = $posts[0]->created_at;
	   $feed->lang = 'en';
	   foreach ($posts as $post)
		   $feed->add($post->title, $post->author, URL::to($post->slug), $post->created_at, $post->description, $post->content);
	   return $feed->render('atom');


Run Our Laravel Application

The command listed below can be used to launch the server and run this example.

php artisan serve

Recommended Posts

View All

Laravel – Where Condition with Two Columns Example

laravel where with two column example, two column where laravel , table column condition in laravel , laravel where column equals column example

Laravel 9 Captcha Tutorial – Create Captcha in Laravel

A CAPTCHA is a challenge-response test used in computing to determine if a user is human. It is an abbreviation for the Completely Automated Public Tu...

whereIn and whereNotIn Query Example in Laravel

In this model, we will see the Laravel whereIn and whereNotIn query model. Laravel whereIn and whereNotIn query example, laravel whereIn, laravel wher...

Laravel Middleware Tutorial With Example

Laravel middleware implements some functionality during the request hit on the specific URI, as its name says.

Laravel Dropbox api File Upload example using league/flysystem-dropbox

Learn how to upload files to Dropbox using Laravel and league/flysystem-dropbox in this step-by-step tutorial. Improve your Laravel skills today!