shikiryu/shikiryurss
Composer 安装命令:
composer require shikiryu/shikiryurss
包简介
A RSS reader and writer
README 文档
README
PHP library reading and creating RSS
disclaimer:
This class is functional. Anyway, use it only if you don't have other choices.
For example, Zend and Symfony got their own RSS factory, don't add another one in.
📚 Table of Contents
📦 Installation
composer install shikiryu/shikiryurss
or
include '/path/to/this/library/autoload.php';
🚀 Usage
How to make it read RSS?
First, we need to load the RSS :
$rss = SRSS::read('http://exemple.com/rss.xml');
Easy, right? Then you can extract general information :
echo $rss->title; // will display blog title
Then, you can take care of articles. You can select a precise article :
$article1 = $rss->getItem(1); // or $rss->getFirst();
Or looping them :
foreach($rss as $article) {
echo '<a href="'.$article->link.'">'. SRSSTools::formatDate('d/m/y', $item->pubDate).' '.$item->title.'';
}
If you like arrays, you can transform the RSS into an array :
$rssArray = $rss->toArray();
You can also save it into your server with :
$rss->save('/www/rss/rss.xml'); // example
Or finally, you can display it with :
$rss->show();
How to make it create RSS?
First, we need to initialize the RSS :
$rss = SRSS::create();
Easy, right? Then you can add general information :
$rss->title = 'My Awesome Blog';
$rss->link = 'http://shikiryu.com/devblog/';
$rss->description = 'is awesome';
Those 3 are mandatory to validate your RSS, other options can be added. Then, you can add articles. Let's imagine $content contains an array from your database.
foreach($content as $item){
$rssitem = new Item(); // we create an item
$rssitem->title = $item["title"]; // adding title (option)
$rssitem->link = $item['link']; // adding link (option)
$rssitem->pubDate = $item["date"]; // date automatically transformed into RSS format (option)
$rssitem->description = $item["text"]; // adding description (mandatory)
$rss->addItem($rssitem); // we add the item into our RSS
}
There are 2 functions to add item. The first one will add items in the order you enter them, from top to bottom.
$rss->addItem($item);
The other one does the opposite and add the next item in top of your RSS
$rss->addItemBefore($item);
✨ Features
- Read every RSS 2.0
- Based on RSS 2.0 specifications.
- Write and validate RSS 2.0 file
- Based on RSS 2.0 specifications.
🛠️ Support
Please open an issue for support.
📝 Contributing
Please contribute using Github Flow. Create a branch, add commits, and open a pull request.
📜 License
Creative Commons Attribution NonCommercial (CC-BY-NC) © Chouchen
All documentation @ http://labs.shikiryu.com/SRSS/#_how.
Contact : https://shikiryu.com/contact
shikiryu/shikiryurss 适用场景与选型建议
shikiryu/shikiryurss 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 6, 最近一次更新时间为 2023 年 04 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 shikiryu/shikiryurss 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 shikiryu/shikiryurss 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: proprietary
- 更新时间: 2023-04-13