| Package Data | |
|---|---|
| Maintainer Username: | willvincent |
| Maintainer Contact: | tcindie@gmail.com (Will Vincent) |
| Package Create Date: | 2015-02-17 |
| Package Last Update: | 2025-02-03 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-11-03 15:23:43 |
| Package Statistics | |
|---|---|
| Total Downloads: | 1,311,439 |
| Monthly Downloads: | 20,611 |
| Daily Downloads: | 608 |
| Total Stars: | 314 |
| Total Watchers: | 16 |
| Total Forks: | 74 |
| Total Open Issues: | 4 |
A simple Laravel 5 service provider for including the SimplePie library.
The Laravel 5 Feeds Service Provider can be installed via Composer by requiring the
willvincent/feeds package in your project's composer.json.
{
"require": {
"willvincent/feeds": "1.1.*"
}
}
If you're using Laravel 5.5 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,
],
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');
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="{{ $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