https://github.com/dg/rss-php
Small and easy-to-use library for consuming RSS and Atom feeds
https://github.com/dg/rss-php
php rss
Last synced: 9 days ago
JSON representation
Small and easy-to-use library for consuming RSS and Atom feeds
- Host: GitHub
- URL: https://github.com/dg/rss-php
- Owner: dg
- License: bsd-3-clause
- Created: 2010-02-03T20:31:25.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T19:01:12.000Z (10 months ago)
- Last Synced: 2025-04-07T00:15:43.269Z (16 days ago)
- Topics: php, rss
- Language: PHP
- Homepage: https://nette.org
- Size: 37.1 KB
- Stars: 474
- Watchers: 29
- Forks: 148
- Open Issues: 7
-
Metadata Files:
- Readme: readme.md
- Funding: .github/funding.yml
- License: license.md
Awesome Lists containing this project
README
RSS & Atom Feeds for PHP
========================[](https://packagist.org/packages/dg/rss-php)
[](https://github.com/dg/rss-php/releases)
[](https://github.com/dg/rss-php/blob/master/license.md)RSS & Atom Feeds for PHP is a very small and easy-to-use library for consuming an RSS and Atom feeds.
It requires PHP 5.3 or newer with CURL extension or enabled allow_url_fopen
and is licensed under the New BSD License. You can obtain the latest version from
our [GitHub repository](https://github.com/dg/rss-php/releases) or install it via Composer:```
composer require dg/rss-php
```[Support Me](https://github.com/sponsors/dg)
--------------------------------------------Do you like RSS? Are you looking forward to the new features?
[](https://github.com/sponsors/dg)
Thank you!
Usage
-----Download RSS feed from URL:
```php
$rss = Feed::loadRss($url);
```The returned properties are SimpleXMLElement objects. Extracting
the information from the channel is easy:```php
echo 'Title: ', $rss->title;
echo 'Description: ', $rss->description;
echo 'Link: ', $rss->url;foreach ($rss->item as $item) {
echo 'Title: ', $item->title;
echo 'Link: ', $item->url;
echo 'Timestamp: ', $item->timestamp;
echo 'Description ', $item->description;
echo 'HTML encoded content: ', $item->{'content:encoded'};
}
```Download Atom feed from URL:
```php
$atom = Feed::loadAtom($url);
```You can also enable caching:
```php
Feed::$cacheDir = __DIR__ . '/tmp';
Feed::$cacheExpire = '5 hours';
```You can setup a User-Agent if needed:
```php
Feed::$userAgent = "FeedFetcher-Google; (+http://www.google.com/feedfetcher.html)";
```If you like it, **[please make a donation now](https://nette.org/make-donation?to=rss-php)**. Thank you!