pixel418 / feedify
Feedify可以将任何数据转换为PHP中的feed
v1.0.0
2013-11-14 13:23 UTC
Requires
- php: >=5.4.0
- twig/twig: 1.*
This package is not auto-updated.
Last update: 2024-09-14 15:27:01 UTC
README
Feedify可以将任何数据转换为PHP中的feed。
目前支持RSS和SiteMap feed。
代码示例
$writer = new \Feedify\Writer(); /* Add global description */ $writer->title = 'Title of my blog'; $writer->description = 'Description of my blog'; $writer->siteURL = 'http://example.com/url/to/my/blog'; $writer->feedURL = 'http://example.com/url/to/my/blog/feed'; /* Add items & formatters */ // Add data from your database $writer->addItems($myData); // The 'date' attribute could be used directly $writer->addAttribute('date'); // The 'title' attribute corresponds to my 'name' attribute $writer->addAttributeMap('title', 'name'); // The 'url' attribute needs a specific formatter $writer->addAttributeFormatter('url', function($article){ return 'http://example.com/article/'.$article->id; }); /* Output */ // As a RSS $writer->output(\Feedify\Writer::RSS_FORMAT); // Or as a SiteMap $writer->output(\Feedify\Writer::SITEMAP_FORMAT);
作者与社区
Feedify遵循MIT许可证。
由Thomas ZILLIOX创建和维护。