jp3cki/yii2-feed
Composer 安装命令:
composer require jp3cki/yii2-feed
包简介
Zend Feed Writer wrapper for Yii Framework 2
README 文档
README
This is a zend feed writer wrapper for Yii 2.
You can put RSS and Atom feeds easy.
License
MIT License.
Copyright © 2018 AIZAWA Hina
Requirements
- PHP 7.1+
Install
composer.phar install jp3cki/yii2-feed
Example
namespace app\controllers; use Yii; use yii\data\ActiveDataProvider; use yii\helpers\Url; use yii\web\Controller; use yii\web\Response; use jp3cki\yii2\feed\Feed; class FeedController extends Controller { public function actionRss() { return $this->feedResponse( Feed::TYPE_RSS, 'application/rss+xml' ); } public function actionAtom() { return $this->feedResponse( Feed::TYPE_ATOM, 'application/atom+xml' ); } private function feedResponse(string $type, string $contentType) { Yii::$app->timeZone = 'Etc/UTC'; // recommended $resp = Yii::$app->response; $resp->format = Response::FORMAT_XML; $resp->formatters[Response::FORMAT_XML]['contentType'] = $contentType; $resp->data = Feed::widget([ // feed type. 'type' => $type, // Feed::TYPE_RSS or Feed::TYPE_ATOM // main data. 'dataProvider' => new ActiveDataProvider([ 'query' => Article::find()->orderBy(['id' => SORT_DESC]), 'pagination' => [ 'pageSize' => 10, ], ]), // channel data. 'title' => Yii::$app->name, 'description' => 'Bla bra bla...', 'copyright' => 'Copyright (C) 2018 AIZAWA Hina', 'link' => Url::home(true), 'rssLink' => Url::to(['feed/rss'], true), 'atomLink' => Url::to(['feed/atom'], true), 'author' => [ 'name' => 'AIZAWA Hina', 'email' => 'hina@bouhime.com', 'uri' => 'https://fetus.jp/', ], 'generator' => [ 'name' => Yii::$app->name, 'version' => Yii::$app->version, 'uri' => Url::home(true), ], 'dateCreated' => null, // null means "now" 'dateModified' => null, 'lastBuildDate' => null, // entry formatters. (like GridView::$columns) 'entry' => [ // 'attrName' => 'value' or // 'attrName' => callback function // // all callback prototype: // function ($model, $key, $feedEntry, $widget): <value> { } 'title' => function ($model): string { return $model['title']; }, 'link' => function ($model): string { return $model['link']; }, 'dateModified' => function ($model) { return $model['dateModified'] ?? null; }, 'dateCreated' => function ($model) { return $model['dateCreated'] ?? null; }, 'description' => function ($model): string { return $model['description']; }, 'content' => function ($model): string { return $model['content']; }, ], ]); return $resp; } }
jp3cki/yii2-feed 适用场景与选型建议
jp3cki/yii2-feed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 98 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 08 月 20 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jp3cki/yii2-feed 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jp3cki/yii2-feed 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 98
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-08-20