2017 © Pedro Peláez
 

library rss

An elegant RSS 2.0 parser.

image

vinelab/rss

An elegant RSS 2.0 parser.

  • Wednesday, October 14, 2015
  • by Vinelab
  • Repository
  • 6 Watchers
  • 37 Stars
  • 24,682 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 15 Forks
  • 6 Open issues
  • 6 Versions
  • 4 % Grown

The README.md

Build Status, (*1)

RSS Client

A simple and radical RSS client that supports RSS 0.92, 2.0 and Atom feeds., (*2)

Synopsis

Fetch Feeds, (*3)

$rss->feed('https://stackoverflow.com/feeds/tag?tagnames=php&sort=newest');

Parse Feeds, (*4)

$feed->info();
$feed->articles();

Installation

composer require vinelab/rss, (*5)

Laravel Setup

Edit app.php and add 'Vinelab\Rss\RssServiceProvider', to the 'providers' array., (*6)

It will automatically alias itself as RSS so no need to aslias it in your app.php unless you would like to customize it. In that case edit your 'aliases' in app.php adding 'MyRSS' => 'Vinelab\Rss\Facades\RSS',, (*7)

Usage

Fetch an RSS feed

require 'vendor/autoload.php';

use Vinelab\Rss\Rss;

$rss = new Rss();
$feed = $rss->feed('https://stackoverflow.com/feeds/tag?tagnames=php&sort=newest');

// $feed is now an instance of Vinelab\Rss\Feed

$info = $feed->info();
$count = $feed->articlesCount();
$articles = $feed->articles();

Feed Info

$info = $feed->info();

echo json_encode($info);
{
   "title": "Newest questions tagged php - Stack Overflow",
   "subtitle": "most recent 30 from stackoverflow.com",
   "updated": "2020-07-16T19:14:29Z",
   "id": "https://stackoverflow.com/feeds/tag?tagnames=php&sort=newest"
 }

Feed Articles

Accessing Articles, (*8)

$articles = $feed->articles();

This will give you an instance of Vinelab\Rss\ArticlesCollection which is an extension of Illuminate\Support\Collection. Each item of this collection is an instance of Vinelab\Rss\Article from which you can safely access any of the properties in the entry., (*9)

Article, (*10)

Is an object which properties are dynamically accessed such as $article->title., (*11)

Whichever fields exist in the feed's entry will be accessible as read-only property, making Article an immutable object., (*12)

You may also call isset($article->someField) to check whether the field exists for a designated entry., (*13)

$article = $articles->first();

echo $article->title; // ABBA piano seen raising money, money, money at auction

echo $article->whatever; // null

Or iterate through the articles, (*14)

foreach ($feed->articles() as $article) {
  $title = $article->title;
}

You may also access the article's original XML format with, (*15)

$article->xml();

Got Questions?

Reach out in the issues., (*16)


MIT LICENSE, (*17)

The Versions

14/10 2015

dev-master

9999999-dev

An elegant RSS 2.0 parser.

  Sources   Download

MIT

The Requires

 

The Development Requires

14/10 2015

v1.0.4

1.0.4.0

An elegant RSS 2.0 parser.

  Sources   Download

MIT

The Requires

 

The Development Requires

01/09 2015

1.0.3

1.0.3.0

An elegant RSS 2.0 parser.

  Sources   Download

MIT

The Requires

 

The Development Requires

27/03 2014

1.0.2

1.0.2.0

An elegant RSS 2.0 parser.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/12 2013

1.0.1

1.0.1.0

An elegant RSS parser.

  Sources   Download

MIT

The Requires

 

The Development Requires

16/12 2013

1.0.0

1.0.0.0

An elegant RSS parser.

  Sources   Download

MIT

The Requires

 

The Development Requires