mayconbordin/rss-l5
RSS builder for Laravel 5
7,407
4
| Install | |
|---|---|
composer require mayconbordin/rss-l5 |
|
| Latest Version: | 1.1 |
| PHP: | >=5.3.0 |
| License: | MIT |
| Last Updated: | Jul 8, 2015 |
| Links: | GitHub · Packagist |
Maintainer: mayconbordin
RSS
RSS builder for Laravel 5
Installation
Add mayconbordin/rss-l5 to composer.json.
"mayconbordin/rss-l5": "~1.1"
Run composer update to pull down the latest version of RSS.
Now open up app/config/app.php and add the service provider to your providers array.
'providers' => array(
'Thujohn\Rss\RssServiceProvider',
)
Now add the alias.
'aliases' => array(
'Rss' => 'Thujohn\Rss\RssFacade',
)
Usage
Returns the feed
Route::get('/', function()
{
$feed = Rss::feed('2.0', 'UTF-8');
$feed->channel([
'title' => "Channel's title",
'description' => "Channel's description",
'link' => "http://www.test.com/"
]);
for ($i=1; $i<=5; $i++) {
$feed->item([
'title' => 'Item '.$i,
'description|cdata' => 'Description '.$i,
'link' => 'http://www.test.com/article-'.$i
]);
}
return response($feed, 200)->header('Content-Type', 'text/xml');
});
Save the feed
Route::get('/', function()
{
$feed = Rss::feed('2.0', 'UTF-8');
$feed->channel([
'title' => "Channel's title",
'description' => "Channel's description",
'link' => "http://www.test.com/"
]);
for ($i=1; $i<=5; $i++) {
$feed->item([
'title' => 'Item '.$i,
'description|cdata' => 'Description '.$i,
'link' => 'http://www.test.com/article-'.$i
]);
}
$feed->save('test.xml');
});