Download the PHP package shevabam/rss-feed-maker without Composer
On this page you can find all versions of the php package shevabam/rss-feed-maker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download shevabam/rss-feed-maker
More information about shevabam/rss-feed-maker
Files in shevabam/rss-feed-maker
Package rss-feed-maker
Short Description Create RSS feeds easily in PHP
License GPL-2.0-only
Homepage https://github.com/shevabam/rss-feed-maker
Informations about the package rss-feed-maker
RSS Feed Maker
Create RSS feeds easily in PHP!
This library allows you to create an XML file representing an RSS feed.
Requirement
- PHP 7.4+
Installation
With Composer, run this command:
composer require shevabam/rss-feed-maker
Usage
First, include the library in your code using the Composer autoloader and then create a Feed object.
Next, configure the feed:
Here are the parameters that can be modified for the feed:
RSS Tag | PHP method | Example | Default | Required |
---|---|---|---|---|
title |
setTitle() | $feed->setTitle('RSS Feed Title'); | Empty | Yes |
description |
setDescription() | $feed->setDescription('Recent articles on your website'); | Empty | Yes |
lastBuildDate |
setLastBuildDate() | $feed->setLastBuildDate(); | Actual date | |
pubDate |
setPubDate() | $feed->setPubDate(); | Empty | |
link |
setLink() | $feed->setLink('https://website.com'); | Empty | Yes |
webMaster |
setWebmaster() | $feed->setWebmaster('John Doe'); | Empty | |
category |
setCategory() | $feed->setCategory('Blog'); | Empty | |
copyright |
setCopyright() | $feed->setCopyright('MyWebsite.com'); | Empty | |
language |
setLanguage() | $feed->setLanguage('en'); | en | |
ttl |
setTtl() | $feed->setTtl(30); | Empty | |
image |
setImage() | $feed->setImage([ 'title' => 'Image title', 'url' => 'https://website.com/Image.jpg', 'link' => 'https://website.com' ]); | Empty |
The language
code is described here: https://www.rssboard.org/rss-language-codes
Default encoding is: utf-8. You can change it with:
Then, create the items and inject them into the feed:
Parameters for item:
RSS Tag | PHP method | Example | Default | Required |
---|---|---|---|---|
title | setTitle() | $item->setTitle('Blog post #1'); | Empty | Yes |
description | setDescription() | $item->setDescription('Post content blabla'); | Empty | Yes |
pubDate | setPubDate() | $item->setPubDate(); | Empty | |
link | setLink() | $item->setLink('https://website.com/post-1'); | Empty | Yes |
author | setAuthor() | $item->setAuthor('John Doe'); | Empty | |
category | setCategory() | $item->setCategory('Tutorials'); | Empty | |
guid | setGuid() | $item->setGuid('https://website.com/...'); | Empty | |
comments | setComments() | $item->setComments('https://website.com/post-1/comments'); | Empty | |
source | setSource() | $item->setSource([ 'url' => 'https://wikipedia...', 'source' => 'Description', ]); | Empty | |
enclosure | setEnclosure() | $item->setEnclosure([ 'url' => 'https://website.com/podcasts/example.mp3', 'length' => 12345, 'type' => 'audio/mpeg', ]); | Empty |
For more information about the RSS schema, please see the specifications.
Finally, generate the XML with:
You can save the RSS feed to a file:
Full example
Result: