juststeveking/feed-parser
A simple feed parser for PHP with zero dependencies.
⭐
4
Stars
📦
3
Downloads
📈
0
Monthly
Feed Generator
A simple feed parser for PHP with zero dependencies.
Why
Most RSS and Atom parsers I have seen are either too complex or have too many dependencies. This is a simple feed parser that can parse both RSS and Atom feeds, with zero dependencies using a simple file_get_contents to fetch the feed itself.
Installation
composer require juststeveking/feed-generator
Usage
This package is designed to be super simple to use.
Parsing Atom Feeds
use JustSteveKing\FeedParser\AtomParser;
use JustSteveKing\FeedParser\FeedIterator;
use JustSteveKing\FeedParser\ValueObjects\AtomEntry;
use JustSteveKing\FeedParser\ValueObjects\AtomFeed;
$iterator = new FeedIterator(
url: 'https://example.com/feed.atom',
parser: new AtomParser(),
);
/** @var AtomFeed $item */
foreach ($iterator as $item) {
echo $item->title(); // The Title of the Feed
echo $item->link(); // The Link of the Feed
echo $item->subtitle(); // The Subtitle of the Feed
echo $item->updated(); // The Updated Date of the Feed
echo $item->rights(); // The Rights of the Feed
echo $item->generator(); // The Generator of the Feed
/** @var AtomEntry $entry */
foreach ($item->entries() as $entry) {
echo $entry->title(); // The Title of the Entry
echo $entry->link(); // The Link of the Entry
echo $entry->id(); // The ID of the Entry
echo $entry->updated(); // The Updated Date of the Entry
echo $entry->summary(); // The Summary of the Entry
echo $entry->content(); // The Content of the Entry
echo $entry->author(); // The Author of the Entry
}
}
Parsing RSS Feeds
use JustSteveKing\FeedParser\RssParser;
use JustSteveKing\FeedParser\FeedIterator;
use JustSteveKing\FeedParser\ValueObjects\RssChannel;
use JustSteveKing\FeedParser\ValueObjects\RssItem;
$iterator = new FeedIterator(
url: 'https://example.com/feed.rss',
parser: new RssParser(),
);
/** @var RssChannel $item */
foreach ($iterator as $item) {
echo $item->title(); // The Title of the Feed
echo $item->link(); // The Link of the Feed
echo $item->description(); // The Description of the Feed
/** @var RssItem $entry */
foreach ($item->items() as $entry) {
echo $entry->title(); // The Title of the Entry
echo $entry->link(); // The Link of the Entry
echo $entry->guid(); // The GUID of the Entry
echo $entry->pubDate(); // The Published Date of the Entry
echo $entry->description(); // The Description of the Entry
echo $entry->author(); // The Author of the Entry
}
}
Testing
You can run the tests using the following command:
composer test
Static Analysis
You can run PHPStan using the following command:
composer stan
Code Style
You can run Laravel Pint using the following command:
composer pint
Refactoring
You can run Rector using the following command:
composer refactor
Credits
LICENSE
The MIT License (MIT). Please see License File for more information.
Last updated: 12/5/2025
← Back to all projects