thujohn / rss
Laravel 4 的 RSS 构建器
1.0.3
2014-12-22 21:07 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.*|5.*
This package is auto-updated.
Last update: 2024-08-24 04:09:09 UTC
README
Laravel 4 的 RSS 构建器
安装
将 thujohn/rss
添加到 composer.json
。
"thujohn/rss": "~1.0"
运行 composer update
以获取 RSS 的最新版本。
现在打开 app/config/app.php
并将服务提供者添加到您的 providers
数组中。
'providers' => array(
'Thujohn\Rss\RssServiceProvider',
)
现在添加别名。
'aliases' => array(
'Rss' => 'Thujohn\Rss\RssFacade',
)
用法
返回饲料
Route::get('/', function()
{
$feed = Rss::feed('2.0', 'UTF-8');
$feed->channel(array('title' => 'Channel\'s title', 'description' => 'Channel\'s description', 'link' => 'http://www.test.com/'));
for ($i=1; $i<=5; $i++){
$feed->item(array('title' => 'Item '.$i, 'description|cdata' => 'Description '.$i, 'link' => 'http://www.test.com/article-'.$i));
}
return Response::make($feed, 200, array('Content-Type' => 'text/xml'));
});
保存饲料
Route::get('/', function()
{
$feed = Rss::feed('2.0', 'UTF-8');
$feed->channel(array('title' => 'Channel\'s title', 'description' => 'Channel\'s description', 'link' => 'http://www.test.com/'));
for ($i=1; $i<=5; $i++){
$feed->item(array('title' => 'Item '.$i, 'description|cdata' => 'Description '.$i, 'link' => 'http://www.test.com/article-'.$i));
}
$feed->save('test.xml');
});