ma4nn/php-rss-writer
Composer 安装命令:
composer require ma4nn/php-rss-writer
包简介
Yet another simple RSS writer library.
关键字:
README 文档
README
\Suin\RSSWriter is yet another simple RSS writer library for PHP. This component is Licensed under MIT license.
This library can also be used to publish Podcasts.
This fork of the original package mainly raises the PHP compatibility level to >= 8.2 and improves code quality.
Quick demo
$feed = new Feed(); $channel = new Channel(); $channel ->title('Channel Title') ->description('Channel Description') ->url('http://blog.example.com') ->feedUrl('http://blog.example.com/rss') ->language('en-US') ->copyright('Copyright 2012, Foo Bar') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->ttl(60) ->pubsubhubbub('http://example.com/feed.xml', 'http://pubsubhubbub.appspot.com') // This is optional. Specify PubSubHubbub discovery if you want. ->appendTo($feed); // Blog item $item = new Item(); $item ->title('Blog Entry Title') ->description('<div>Blog body</div>') ->contentEncoded('<div>Blog body</div>') ->url('http://blog.example.com/2012/08/21/blog-entry/') ->author('john@smith.com') ->creator('John Smith') ->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900')) ->guid('http://blog.example.com/2012/08/21/blog-entry/', true) ->preferCdata(true) // By this, title and description become CDATA wrapped HTML. ->appendTo($channel); // Podcast item $item = new Item(); $item ->title('Some Podcast Entry') ->description('<div>Podcast body</div>') ->url('http://podcast.example.com/2012/08/21/podcast-entry/') ->enclosure('http://podcast.example.com/2012/08/21/podcast.mp3', 4889, 'audio/mpeg') ->appendTo($channel); echo $feed; // or echo $feed->render();
Output:
<?xml version="1.0" encoding="UTF-8"?> <rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"> <channel> <title>Channel Title</title> <link>http://blog.example.com</link> <description>Channel Description</description> <language>en-US</language> <copyright>Copyright 2012, Foo Bar</copyright> <pubDate>Tue, 21 Aug 2012 10:50:37 +0000</pubDate> <lastBuildDate>Tue, 21 Aug 2012 10:50:37 +0000</lastBuildDate> <ttl>60</ttl> <atom:link rel="self" href="http://example.com/feed.xml" type="application/rss+xml"/> <atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/> <item> <title><![CDATA[Blog Entry Title]]></title> <link>http://blog.example.com/2012/08/21/blog-entry/</link> <description><![CDATA[<div>Blog body</div>]]></description> <content:encoded><![CDATA[<div>Blog body</div>]]></content:encoded> <guid>http://blog.example.com/2012/08/21/blog-entry/</guid> <pubDate>Tue, 21 Aug 2012 10:50:37 +0000</pubDate> <author>john@smith.com</author> <creator>John Smith</creator> </item> <item> <title>Some Podcast Entry</title> <link>http://podcast.example.com/2012/08/21/podcast-entry/</link> <description><div>Podcast body</div></description> <enclosure url="http://podcast.example.com/2012/08/21/podcast.mp3" type="audio/mpeg" length="4889"/> </item> </channel> </rss>
Installation
Easy installation
You can install directly via composer:
$ composer require ma4nn/php-rss-writer
How to use
The examples directory contains usage examples for RSSWriter.
If you want to know APIs, please see FeedInterface, ChannelInterface and ItemInterface.
How to Test
$ vendor/bin/phpunit
Test older PHP versions with Docker
$ docker-compose up
License
MIT license
ma4nn/php-rss-writer 适用场景与选型建议
ma4nn/php-rss-writer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 264 次下载、GitHub Stars 达 3, 最近一次更新时间为 2024 年 07 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「generator」 「php」 「feed」 「rss」 「writer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ma4nn/php-rss-writer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ma4nn/php-rss-writer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ma4nn/php-rss-writer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Memio's PrettyPrinter, used to generate PHP code from given Model
Simple RSS generator library for PHP 5.5 or later. clone from Bhaktaraz Bhatta ttps://github.com/bhaktaraz/php-rss-generator
Google Shopping Feed API (with ns problem fixed)
This module is designed to provide a special alerts feed block for Howard University
Alfabank REST API integration
Phalcon Model Generator
统计信息
- 总下载量: 264
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-12