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.
Open your database server and create database like this:
Next, open .env file and setup database credentials like this:
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.
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:
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:
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
Enter the URL: 127.0.0.1:8000/feed and you will get your feed like this:
Tags: Laravel RSS/XML Feed