ahmedfawzy/feeds
Composer 安装命令:
composer require ahmedfawzy/feeds
包简介
Laravel 5 Service Provider for the SimplePie library
README 文档
README
A simple Laravel 5 service provider for including the SimplePie library.
Installation
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.*"
}
}
Configuration
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, Facades must either be prefixed with a backslash, or brought into scope with a use [facadeName] declaration.
Example controller method, and it's related view:
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); }
Multifeeds example controller method, and it's related view:
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
ahmedfawzy/feeds 适用场景与选型建议
ahmedfawzy/feeds 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 23 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 07 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 ahmedfawzy/feeds 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ahmedfawzy/feeds 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 23
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-20