2017 © Pedro Peláez
 

library rss

moell/rss is a package that follows the RSS 2.0 standard

image

moell/rss

moell/rss is a package that follows the RSS 2.0 standard

  • Monday, November 28, 2016
  • by moell
  • Repository
  • 1 Watchers
  • 11 Stars
  • 540 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 2 Versions
  • 60 % Grown

The README.md

moell/rss

moell/rss is a package that follows the RSS 2.0 standard, (*1)

RSS specification

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

中文README

README, (*3)

Requirement

PHP >= 5.4.0, (*4)

Installation

composer require "moell/rss:1.*"

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

$rss = new \Moell\Rss\Rss();

$channel = [
    'title' => 'title',
    'link'  => 'http://moell.cn',
    'description' => 'description',
    'category' => [
        'value' => 'html',
        'attr' => [
            'domain' => 'http://www.moell.cn'
        ]
    ]
];

$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);
}

echo $rss;  //Get xml

//Other acquisition methods
$rss->build()->asXML();

$rss->fastBuild($channel, $items)->asXML();

$rss->channel($channel)->items($items)->build()->asXML();

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

moell/rss is a package that follows the RSS 2.0 standard

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar moell

rss

28/11 2016

1.0.1

1.0.1.0

moell/rss is a package that follows the RSS 2.0 standard

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

by Avatar moell

rss