- What is Laravel?
- Upgrade Laravel To 8.X
- Role Management
- Newsletter Package
- Laravel Vs WordPress CMS
- New Laravel 6.X
- How To Make API In Laravel
- Laravel RSS/XML Feed
- How To Make Theme In Laravel?
- Laravel Project Testing Using PHPunit
- Laravel Package
- Make Contact Form In Laravel
- Laravel Homestead
- Laravel Cron Job
- What is Composer
- How to create an Admin-Panel in Laravel
- Admin Panel in Laravel
- Installation of Laravel in Windows
- Laravel Development
- Benefits of Laravel
- Laravel Notification
- How to make a Blog in Laravel
- Laravel Authentication
RSS is the type of web feed that allows users and applications to receive regular updates from a website or blog of their choice. RSS stands for Rich Site Summary or it often called Really Simple Syndication. RSS feed is read by an RSS reader or a feed reader, which can be web based, a standalone desktop application or a mobile application.
An RSS fee is delivered in XML format, allowing maximum compatibility between readers.
In this article, we are going to use laravelium/feed package for generating RSS feed in Laravel application. So, let’s follow the steps below:
Step1: Install Laravel Project:
Open your terminal and run the composer command: “composer create-project –prefer-dist laravel/laravel RssFeed”
Step2: Install the Packages
Step2: Install the Packages
In this step we have to install laravelium/feed package using “composer require laravelium/feed” command.
After installing the package, we have to add service provider under providers array and aliases array.
Open “config/app.php” file and add service “Laravelium\Feed\FeedServiceProvider::class,” under providers array like this:
Next, add services under aliases array like this:
Publish Configure File:
Run the command in your terminal for publishing the configure file:
php artisan vendor:publish –provider=“Laravelium\Feed\FeedServiceProvider”. This process is optional, so, you can skip out this process.
Step3: Configure SQL Database
Open your database server and create database like this:
Next, open .env file and setup database credentials like this:
Step4: Create Model:
Next, we have to create model and migration file. So, run the command: php artisan make:model Post –m, here “-m” will create migration file also.
After running the artisan command, open migration create_posts_table.php file and add line of code like this:
Next, run the migrate command: php artisan migrate. This command will create tables in your database.
Step5: Creating Dummy data:
Now we will create dummy data in your database. Open the database/factories/UserFactory.php file and add the fake table like this:
Open database/seeds/DatabaseSeeder.php file and add the line like this:
Next, run database seed command; php artisan db:seed
After running seed command, 50 records of data feed into post table. You can see database post table like this:
Step6: Create Controller:
Now we have to create the controller for rss-feed. Run the command:
php artisan make:controller PostController
Next, open the “app/Http/Controller/PostController.php” file and add the following:
Step7: Define The Routes:
Open routes/web.php file and define your routes like this:
Next, open the resources/views/welcome.blade.php file and add an RSS link to the welcome page by adding Feed::link in the
Step8: Navigate The Browser:
Enter the URL: 127.0.0.1:8000/feed and you will get your feed like this: