rwslinkman/simple-rss-feed-renderer 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rwslinkman/simple-rss-feed-renderer

最新稳定版本:1.5.0

Composer 安装命令:

composer require rwslinkman/simple-rss-feed-renderer

包简介

Basic object-to-RSS renderer for hosting an RSS feed

README 文档

README

Basic object-to-RSS renderer for hosting an RSS feed

Installation

Add simple-rss-feed-renderer to your dependencies using Composer:

composer require rwslinkman/simple-rss-feed-renderer

Usage

Please find below an example of how to use SimpleXmlFeedRenderer.
The FeedBuilder can be used to create data objects.
Most properties in the RSS 2.0 specification are configurable.
Not all configurable properties are shown in the example below.

// Article content loaded in a way preferred by you
$articlesList = array(...);

$feedBuilder = (new FeedBuilder())
    ->withChannelTitle("Fun facts")
    ->withChannelDescription("Daily fun facts for you to read")
    ->withChannelUrl("https://funfacts.nl/articles");

foreach ($articlesList as $article) {
    $feedBuilder
        ->addItem()
        ->withTitle($article->getTitle())
        ->withDescription($article->getSubtitle())
        ->withLink("https://funfacts.nl/articles/" . $article->getId())
        ->withPubDate($article->getCreatedAt())
        ->buildItem();
}
$rssFeed = $feedBuilder->build();

// Don't forget to set "application/rss+xml" for the "Content-Type" header
$renderer = new SimpleRssFeedRenderer();
$renderer->configurePrettyPrint(true);
$renderer->configureValidateBeforeRender(true);
$rssXml = $renderer->render($rssFeed);

When configured, the renderer will perform RSS 2.0 validations on all provided data in the RssFeed object.
The RssValidator can also be run separately:

$feedBuilder = (new FeedBuilder())
    ->withChannelTitle("Fun facts")
    ->withChannelDescription("Daily fun facts for you to read")
    ->withChannelUrl("https://funfacts.nl/articles");
$rssFeed = $feedBuilder->build();

// it will throw InvalidRssException containing the ValdationReport in case of errors
$validator = new RssValidator();
$validator->validate($rssFeed);

Other

Run phpunit tests with or without coverage:

./scripts/run_phpunit.sh 
./scripts/run_phpunit_coverage.sh 

Mutation tests can be run using the Infection framework.
Install the framework locally as described on the website.
After installing, run the following command from the project root folder:

infection --threads=10

统计信息

  • 总下载量: 22
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2022-11-06