lukaswhite/php-feed-writer
Composer 安装命令:
composer create-project lukaswhite/php-feed-writer
包简介
A PHP library for writing feeds; e.g. RSS
README 文档
README
A PHP library for writing feeds. Currently supports RSS 2.0, Atom and iTunes, along with support for MediaRSS, Dublin Core, GeoRSS and WordPress eXtended RSS (WXR).
Features
- Modern (PHP7.1+)
- Flexible; use it for syndication, media, podcasts...
- Fast
- Easy to extend
- Supports custom namespaces
- Full MediaRSS support
- Dublin Core Support
- GeoRSS support
- Supports XSL stylesheets
- No third-party dependencies
- Fully tested
Simple Examples
RSS
$feed = new RSS2( ); $channel = $feed->addChannel( ); $channel ->title( 'My Blog' ) ->description( 'My personal blog' ) ->link( 'https://example.com' ) ->lastBuildDate( new \DateTime( ) ) ->pubDate( new \DateTime( ) ) ->language( 'en-US' ); foreach( $posts as $post ) { $channel->addItem( ) ->title( $post->title ) ->description( $post->description ) ->link( $post->url ) ->pubDate( $post->publishedAt ) ->guid( $post->url, true ); }
RSS in Laravel
$feed = new RSS2( ); // ... return response( )->make( $feed->toString( ), 200, [ 'Content-Type' => $feed->getMimeType( ), ] );
Atom
$feed = new \Lukaswhite\FeedWriter\Atom( ); $feed->title( 'Example Feed' ) ->link( 'http://example.org/' ) ->updated( new \DateTime( '2003-12-13T18:30:02Z' ) ) ->id( 'urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6' ); foreach( $posts as $post ) { $feed->addEntry( ) ->title( $post->title ) ->id( $post->id ) ->updated( $post->updatedAt ); }
iTunes
$feed = new Itunes( ); $channel = $feed->addChannel( ); $channel->title( 'All About Everything' ) ->subtitle( 'A show about everything' ) ->description( 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' ) ->summary( 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' ) ->link( 'http://www.example.com/podcasts/everything/index.html' ) ->image( 'http://example.com/podcasts/everything/AllAboutEverything.jpg' ) ->author( 'John Doe' ) ->owner( 'John Doe', 'john.doe@example.com' ) ->explicit( 'no' ) ->copyright( '℗ & © 2014 John Doe & Family' ) ->generator( 'Feed Writer' ) ->ttl( 60 ) ->lastBuildDate( new \DateTime( '2016-03-10 02:00' ) ); $channel->addCategory() ->term('Technology'); $channel->addCategory() ->term('Sports') ->children('Football', 'Soccer'); $channel->addItem( ) ->title( 'Shake Shake Shake Your Spices' ) ->author( 'John Doe' ) ->subtitle( 'A short primer on table spices' ) ->duration( '07:04' ) ->summary( 'This week we talk about <a href="https://itunes/apple.com/us/book/antique-trader-salt-pepper/id429691295?mt=11">salt and pepper shakers</a>, comparing and contrasting pour rates, construction materials, and overall aesthetics. Come and join the party!' ) ->pubDate( new \DateTime( '2016-03-08 12:00' ) ) ->guid( 'http://example.com/podcasts/archive/aae20140615.m4a' ) ->explicit( 'no' ) ->addEnclosure( ) ->url( 'http://example.com/podcasts/everything/AllAboutEverythingEpisode3.m4a' ) ->length( 8727310 ) ->type( 'audio/x-m4a' );
Installation
This package requires PHP 7.1+.
Install the package using Composer:
composer require lukaswhite\php-feed-writer
Documentation
Full documentation can be found here.
lukaswhite/php-feed-writer 适用场景与选型建议
lukaswhite/php-feed-writer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 30.08k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 09 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lukaswhite/php-feed-writer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lukaswhite/php-feed-writer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 30.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-09-11