2017 © Pedro Peláez
 

library laravel-rss

Based on moell/rss development laravel version

image

moell/laravel-rss

Based on moell/rss development laravel version

  • Monday, November 28, 2016
  • by moell
  • Repository
  • 1 Watchers
  • 10 Stars
  • 503 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 2 Versions
  • 67 % Grown

The README.md

moell/rss

Laravel package developed on the basis of moell/rss, (*1)

RSS specification

http://www.rssboard.org/rss-specification, (*2)

中文README

README, (*3)

Requirement

Laravel 5+, (*4)

Installation

composer require moell/laravel-rss:1.*

Modify config/app.php

#Append in providers
Moell\LaravelRss\RssServiceProvider::class,

#Append in aliases
'Rss'   => Moell\LaravelRss\RssFacade::class,

Provides an interface


public function setEncode($encode); //默认UTF-8 public function channel(array $channel); public function item(array $item); public function items(array $items); public function build(); public function fastBuild(array $channel, array $item); public function __toString();

Usage


namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Requests; use Rss; class RssController extends Controller { public function index() { $channel = [ 'title' => 'title', 'link' => 'http://moell.cn', 'description' => 'description', 'category' => [ 'value' => 'html', 'attr' => [ 'domain' => 'http://www.moell.cn' ] ] ]; $rss = Rss::channel($channel); $items = []; for($i = 0; $i < 2; $i++) { $item = [ 'title' => "title".$i, 'description' => 'description', 'source' => [ 'value' => 'moell.cn', 'attr' => [ 'url' => 'http://www.moell.cn' ] ] ]; $items[] = $item; $rss->item($item); } return response($rss, 200, ['Content-Type' => 'text/xml']); //Other acquisition methods //return response($rss->build()->asXML(), 200, ['Content-Type' => 'text/xml']); //return response($rss->fastBuild($channel, $items)->asXML(), 200, ['Content-Type' => 'text/xml']); //return response($rss->channel($channel)->items($items)->build()->asXML(), 200, ['Content-Type' => 'text/xml']); } }

Generate results


<rss
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
    <channel>
        <title>title</title>
        <link>http://moell.cn</link>
        <description>description</description>
        <category domain="http://www.moell.cn">html</category>
        <item>
            <title>title0</title>
            <description>description</description>
            <source url="http://www.moell.cn">moell.cn</source>
        </item>
        <item>
            <title>title1</title>
            <description>description</description>
            <source url="http://www.moell.cn">moell.cn</source>
        </item>
    </channel>
</rss>

License

MIT, (*5)

The Versions

28/11 2016

dev-master

9999999-dev

Based on moell/rss development laravel version

  Sources   Download

MIT

The Requires

 

by Avatar moell

laravel rss

28/11 2016

1.0.1

1.0.1.0

Based on moell/rss development laravel version

  Sources   Download

MIT

The Requires

 

by Avatar moell

laravel rss