moell/rss 好用的轮子,轻松实现网站RSS功能,遵循RSS2.0标准

news/2025/4/22 0:59:06

moell/rss

moell/rss是遵循RSS2.0标准的PHP包,Laravel版本请查看moell/laravel-rss

源码地址

moell/rss
moell/laravel-rss

RSS规范

http://www.rssboard.org/rss-specification

要求

PHP >= 5.4.0

安装

composer require "moell/rss:1.*"

提供接口

//设置字符集
public function setEncode($encode); //默认UTF-8public function channel(array $channel);public function item(array $item);public function items(array $items);//构造xml
public function build();//快速构造
public function fastBuild(array $channel, array $item);public function __toString();

用法

$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;    //获取xml//其他获取方式
$rss->build()->asXML();$rss->fastBuild($channel, $items)->asXML();$rss->channel($channel)->items($items)->build()->asXML();

生成结果

<?xml version="1.0" encoding="UTF-8"?>
<rssxmlns: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

如果你喜欢本项目,欢迎star。GitHub
转帖需说明文章出处:http://moell.cn/article/25


https://dhexx.cn/news/show-3652141.html

相关文章

比喻服务器性能,怎么理解服务器?

我们经常会听到或者是解除到服务器这个词&#xff0c;但是如果不是专门对服务器有进行过了解&#xff0c;相信关于什么是服务器&#xff0c;大家只能有一个模糊的概念。要想选择对服务器&#xff0c;那么了解服务器的基础是不能少的&#xff0c;特别是现在云服务器的潮流中&…

python-----deepcopy和copy的区别

话不多说,直接上代码 import copy n1 [1,2,[1,2,3],4,5] n3 copy.copy(n1) #浅拷备 n3[1] "copy" print(n1,n1) print(n3,n3)****************** n1 [1, 2, [1, 2, 3], 4, 5] n3 [1, copy, [1, 2, 3], 4, 5] ******************import copy n1 [1,2,[1,2,3]…

网站服务器空间域名绑定,服务器空间怎么绑定域名

服务器空间怎么绑定域名 内容精选换一换一个网卡只能绑定一个EIP。您需要多个EIP时&#xff0c;可以将EIP绑定到扩展网卡&#xff0c;但扩展网卡绑定EIP以后&#xff0c;需要在裸金属服务器内根据实际网络情况做相应的操作&#xff0c;例如&#xff1a;增加策略路由或者命名空间…

JavaScript高阶函数 map reduce filter sort

本文是笔者在看廖雪峰老师JavaScript教程时的个人总结高阶函数一个函数就接收另一个函数作为参数&#xff0c;这种函数就称之为高阶函数1.高阶函数之map&#xff1a;此时我们有一个数组和一个接受一个参数并返回一个数的函数。我们需要把这个数组的每一个值在这个函数上走一遍&…

Word 2007切换窗口后鼠标不能点的问题补充

换了Win 7后发现Word 2007只要切换其他窗口后切换回来&#xff0c;鼠标就没用了&#xff0c;在网上找到解决方案&#xff08;包括具体现象描述&#xff09;&#xff1a;http://naci007.javaeye.com/blog/282581但是我没有装PowerDesigner12&#xff0c;在COM加载项里也找不到Po…

关于if (!cin)以及while (cin word)

首先注意&#xff1a; 1、每一个输入&#xff08;输出&#xff09;对象就代表一个输入&#xff08;输出&#xff09;流&#xff1b; 2、输入&#xff08;输出&#xff09;对象中的流状态成员标记了输入&#xff08;输出&#xff09;流当前的状况&#xff0c;当eofbit、badbit、…

mqtt 服务器 性能测试,mqtt(4):mqtt-benchmark 对mqtt 服务进行压力测试-Go语言中文社区...

前言1&#xff0c;关于mqtt-benchmark使用 golang 编写的 mqtt 的基准测试工具。有两个github 项目&#xff1a;使用的是这个&#xff0c;进行基准测试&#xff0c;带vendor 文件夹。展示的结果好看些。https://github.com/krylovsk/mqtt-benchmark2&#xff0c;使用go get gol…

iptables学习总结

一、iptables 基础1、容器&#xff1a;包含或者说属于的关系2、Netfilter/iptables是表的容器&#xff0c;iptables包含的各个表&#xff08;filter&#xff0c;NAT&#xff0c;MANGLE&#xff0c;RAW&#xff09;3、iptables的表tables又是链的容器链chains&#xff1a;INPUT,…

小数据池/is和==/再谈编码作业

# 1&#xff0c;老男孩好声选秀大赛评委在打分的时候呢, 可以输入分数. 假设, 老男孩有10个评委. 让10个评委进行打分, 要求, 分数必须高于5分, 低于10分.将每个评委的打分情况保存在列表中. pingwei [alex, wusir, 麻花藤, 东风扇, 西风扇, 宝宝, 太白, 日天, 女神, 老弟] #方…

ultraedit中换行键的替换

1.ultraedit中换行键使用^r^n