Package Data | |
---|---|
Maintainer Username: | HyanCat |
Maintainer Contact: | hyancat@live.cn (HyanCat) |
Package Create Date: | 2015-05-15 |
Package Last Update: | 2016-10-30 |
Home Page: | |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:08:57 |
Package Statistics | |
---|---|
Total Downloads: | 557 |
Monthly Downloads: | 1 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 3 |
Total Forks: | 0 |
Total Open Issues: | 0 |
RSS builder for Laravel 5
Pull down the package with composer:
composer require hyancat/larss
Add the service provider to your providers array in app/config/app.php
file.
'Hyancat\Larss\LarssServiceProvider'
At last, add the alias to the alias array in app/config/app.php
file.
'RSS' => 'Hyancat\Larss\LarssFacade',
$rss = \RSS::make();
if (! $rss->caching(10)) {
// make channel.
$rss->channel([
'title' => 'title',
'description' => 'description',
'link' => 'http://www.xxx.yyy',
])->withImage([
'url' => 'http://www.xxx.yyy/logo.png',
'title' => 'title',
'link' => 'http://www.xxx.yyy',
]);
// gen posts data ......
foreach ($posts as $post) {
$rss->item([
'title' => $post->title,
'description|cdata' => $post->body,
'link' => $post->url,
// ......
]);
}
}
// If you want to save the rss data to file.
$rss->save('rss.xml');
// Or just make a response to the http request.
return \Response::make($rss->render(), 200, ['Content-Type' => 'text/xml']);
// make with channel.
$rss = \RSS::make()->channel([
'title' => 'title',
'description' => 'description',
'link' => 'http://www.xxx.yyy',
// ......
])->withImage([
'url' => 'http://www.xxx.yyy/logo.png',
'title' => 'title',
'link' => 'http://www.xxx.yyy',
]);
// gen posts data ......
foreach ($posts as $post) {
$rss->item([
'title' => $post->title,
'description|cdata' => $post->body,
'link' => $post->url,
// ......
]);
}
return ...;