michaelhall / rss-feed
Simple RSS feed creator for PHP
Installs: 1 179
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=8.0
- ext-simplexml: *
- datatypes/datatypes: ^3.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2024-11-19 20:59:10 UTC
README
Simple RSS feed creator.
Requirements
- PHP >= 8.0
Install with composer
$ composer require michaelhall/rss-feed
Basic usage
<?php require __DIR__ . '/vendor/autoload.php'; use DataTypes\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;
Add an image to the 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);
License
MIT