scubaclick/feeder

将 feeds(json, rss, atom)添加到 Eloquent 模型

此包的官方仓库似乎已不存在,因此该包已被冻结。

v1.0 2013-09-22 16:42 UTC

This package is auto-updated.

Last update: 2020-02-11 19:07:41 UTC


README

将 RSS、Atom 和 JSON feeds 添加到 Eloquent 模型。由于仍在为 ScubaClick 开发中,因此目前请谨慎使用!

稳定版本

v1.0

安装

通过在 composer.json 中的 require 块中添加以下内容进行安装

"scubaclick/feeder": "dev-master"

然后运行 composer update

Laravel 特定安装

然后在 app/config/app.php 中将以下内容添加到服务提供者数组中

'ScubaClick\Feeder\Providers\LaravelServiceProvider',

然后在别名数组中添加以下内容

'Feeder' => 'ScubaClick\Feeder\Facades\LaravelFacade',

要更改配置值,请在控制台中运行以下命令

php artisan config:publish scubaclick/feeder

生成 feeds

要真正生成任何 feeds,您的模型必须实现 ScubaClick\Feeder\Contracts\FeedInterface 接口。它仅包含一个方法,即 getFeedItem($format),该方法应返回以下数组

[
    'title'       => $title,
    'author'      => $author,
    'link'        => $link,
    'pubDate'     => $pubdate,
    'description' => $description,
];

用法

您可以使用如下方式使用饲料类,例如在控制器中

$items = Post::orderBy('created_at', 'desc')
	->take(10)
	->get();

return Feeder::setChannel([
	    'title'       => 'Feed title',
	    'description' => 'Feed description',
	])
	->setFormat('atom')
	->setItems($items)
	->fetch();

致谢

感谢 laravel4-feed 提供的 feed 模板。

许可证

ScubaClick Feeder 在 MIT 许可证下授权。