PHP code example of michaelhall / rss-feed

1. Go to this page and download the library: Download michaelhall/rss-feed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

michaelhall / rss-feed example snippets




ataTypes\Net\Url;
use MichaelHall\RssFeed\RssFeed;
use MichaelHall\RssFeed\RssItem;

// Create the feed.
$feed = new RssFeed(
    'Feed Title',
    Url::parse('https://example.com/'),
    'The feed description.'
);

// This is optional but recommended by W3C feed validator.
$feed->setFeedUrl(Url::parse('https://example.com/path/to/feed'));

// Add an item.
$feedItem = new RssItem(
    'Item Title',
    Url::parse('https://example.com/path/to/item-page'),
    'The item description',
    new DateTimeImmutable('2017-08-22 19:56:00')
);

$feed->addItem($feedItem);

// Prints the RSS feed.
echo $feed;

use MichaelHall\RssFeed\RssImage;

$feedImage = new RssImage(
    Url::parse('https://example.com/path/to/image'),
    'Image Title',
    Url::parse('https://example.com/')
);

$feed->setImage($feedImage);