New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

willvincent/feeds

Laravel Service Provider for the SimplePie library
1,656,877 312
Install
composer require willvincent/feeds
Latest Version:v2.7.0
PHP:>=5.4.0 || ^7.2 || ^8.0
Laravel:5 – 12
License:MIT
Last Updated:Feb 3, 2025
Links: GitHub  ·  Packagist
Maintainer: willvincent

Laravel Feeds

Latest Stable Version SensioLabsInsight License

Total Downloads Monthly Downloads Daily Downloads

A simple Laravel 5/6/7/8/9/10 service provider for including the SimplePie library.

Installation

The Laravel 5/6/7/8/9/10 Feeds Service Provider can be installed via Composer by requiring the willvincent/feeds package in your project's composer.json.

{
    "require": {
        "willvincent/feeds": "2.3.*"
    }
}

Configuration

If you're using Laravel 5.5 or newer you may skip the next step.

To use the Feeds Service Provider, you must register the provider when bootstrapping your Laravel application.

Find the providers key in your config/app.php and register the Service Provider.

    'providers' => [
        // ...
        willvincent\Feeds\FeedsServiceProvider::class,
    ],

Find the aliases key in your config/app.php and register the Facade.

    'aliases' => [
        // ...
        'Feeds'    => willvincent\Feeds\Facades\FeedsFacade::class,
    ],

Usage

Run php artisan vendor:publish --provider="willvincent\Feeds\FeedsServiceProvider" to publish the default config file, edit caching setting withing the resulting config/feeds.php file as desired.

See SimplePie Documentation for full API usage documentation.

The make() accepts 3 paramaters, the first parameter is an array of feed URLs, the second parameter is the max number of items to be returned per feed, and while the third parameter is a boolean which you can set to force to read unless content type not a valid RSS.

$feed = \Feeds::make('http://feed/url/goes/here');
Note: In Laravel 5 and newer, Facades must either be prefixed with a backslash, or brought into scope with a use [facadeName] declaration.

Controller:

  public function demo() {
    $feed = \Feeds::make('http://blog.case.edu/news/feed.atom');
    $data = array(
      'title'     => $feed->get_title(),
      'permalink' => $feed->get_permalink(),
      'items'     => $feed->get_items(),
    );

    return View::make('feed', $data);
  }

or Force to read unless content type not a valid RSS

  public function demo() {
    $feed = \Feeds::make('http://blog.case.edu/news/feed.atom', true); // if RSS Feed has invalid mime types, force to read
    $data = array(
      'title'     => $feed->get_title(),
      'permalink' => $feed->get_permalink(),
      'items'     => $feed->get_items(),
    );

    return View::make('feed', $data);
  }

Controller:

  public function demo() {
    $feed = \Feeds::make([
        'http://blog.case.edu/news/feed.atom',
        'http://tutorialslodge.com/feed'
    ], 5);
    $data = array(
      'title'     => $feed->get_title(),
      'permalink' => $feed->get_permalink(),
      'items'     => $feed->get_items(),
    );

    return View::make('feed', $data);
  }

or Force to read unless content type not a valid RSS

  public function demo() {
        $feed = \Feeds::make(['http://blog.case.edu/news/feed.atom',
        'http://tutorialslodge.com/feed'
    ], 5, true); // if RSS Feed has invalid mime types, force to read
    $data = array(
      'title'     => $feed->get_title(),
      'permalink' => $feed->get_permalink(),
      'items'     => $feed->get_items(),
    );

    return View::make('feed', $data);
  }

View:

@extends('app')

@section('content')
  <div class="header">
    <h1><a href="https://github.com/willvincent/feeds/blob/HEAD/{{ $permalink }}">{{ $title }}</a></h1>
  </div>

  @foreach ($items as $item)
    <div class="item">
      <h2><a href="{{ $item->get_permalink() }}">{{ $item->get_title() }}</a></h2>
      <p>{{ $item->get_description() }}</p>
      <p><small>Posted on {{ $item->get_date('j F Y | g:i a') }}</small></p>
    </div>
  @endforeach
@endsection

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

660,512,042 9,702
laravel/framework

The Laravel Framework.

625,568,548 34,998
laravel/tinker

Powerful REPL for the Laravel framework.

531,591,559 7,442
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

450,320,528 608
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

424,642,029 4,662

Version History

Version Released PHP Laravel License
v2.7.0 >=5.4.0 || ^7.2 || ^8.0 ~5.0 || ^6.0 || ^7.0 || ^8.0|^9.0|^10.0 || ^11.0 || ^12.0 MIT
v2.6.0 >=5.4.0 || ^7.2 || ^8.0 ~5.0 || ^6.0 || ^7.0 || ^8.0|^9.0|^10.0 || ^11.0 MIT
v2.5.0 >=5.4.0 || ^7.2 || ^8.0 ~5.0 || ^6.0 || ^7.0 || ^8.0|^9.0|^10.0 MIT
v2.4.0 >=5.4.0 || ^7.2 || ^8.0 ~5.0 || ^6.0 || ^7.0 || ^8.0|^9.0 MIT
v2.3.0 >=5.4.0 || ^7.2 ~5.0 || ^6.0 || ^7.0 || ^8.0|^9.0 MIT