lukaswhite/podcast-feed-validator
Composer 安装命令:
composer require lukaswhite/podcast-feed-validator
包简介
A PHP library for validating podcast feeds
README 文档
README
A PHP library for validating podcast feeds.
Checks the validity of the feed; for example whether it's XML, RSS, whether it has the appropriate namespace.
It warns if certain fields are missing; for example, the fields that iTunes requires.
It also recommends fields that iTunes recommend, but which are not required.
Note that I deliberately haven't added a method to fetch a remote feed, so as not to add additional dependencies; I'd recommend using Guzzle.
Installation
composer require lukaswhite/podcast-feed-validator
Usage
use Lukaswhite\PodcastFeedValidator\Validator; $validator = new Validator(); $validator->load('/path/to/feed.rss'); // or $validator->setContent(/** raw content */); $result = $validator->run(); if ($result->fails()) { // ...do something }
The Result
The return value is an object that encapsulates the errors, warnings and recommendations.
Each of these are just strings, and are defined as constants in the relevant classes.
Note that typically, if an error has occurred then validation has failed before it starts generating warnings or recommendations. For example if the provided feed isn't XML, then it cannot check for the existence of certain fields.
if ($result->hasErrors()) { foreach ($result->getErrors() as $error) { } } if ($result->hasWarnings()) { foreach ($result->getWarnings() as $error) { } } if ($result->hasRecommendations()) { foreach ($result->getRecommendations() as $error) { } }
The result object also includes individual results for the episodes.
Example
Suppose you provide the following XML:
<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:rawvoice="http://www.rawvoice.com/rawvoiceRssModule/" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" > <channel> <title>Minimal Example</title> <link>https://example.com</link> <description>Just an example.</description> <item> <title>Episode One</title> </item> </channel> </rss>
This will return FALSE:
$result->hasErrors();
The following will all return TRUE:
$result->hasWarnings(); $result->hasWarning(Warning::NO_LANGUAGE); $result->hasWarning(Warning::NO_ARTWORK); $result->hasWarning(Warning::NO_CATEGORIES); $result->hasWarning(Warning::NO_EXPLICIT);
It will also make recommendations, so the following will also return TRUE:
$result->hasRecommendations(); $result->hasRecommendation(Recommendation::ADD_AUTHOR); $result->hasRecommendation(Recommendation::ADD_OWNER);
For the episode:
$result = $validator->run()->episodes()[0]; $result->hasWarning(Warning::NO_MEDIA); $result->hasRecommendation(Recommendation::ADD_LINK); $result->hasRecommendation(Recommendation::ADD_GUID); $result->hasRecommendation(Recommendation::ADD_PUB_DATE); $result->hasRecommendation(Recommendation::ADD_DESCRIPTION); $result->hasRecommendation(Recommendation::ADD_EXPLICIT); $result->hasRecommendation(Recommendation::ADD_ARTWORK); $result->hasRecommendation(Recommendation::ADD_DURATION);
See the tests for more information.
lukaswhite/podcast-feed-validator 适用场景与选型建议
lukaswhite/podcast-feed-validator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 459 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 12 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 lukaswhite/podcast-feed-validator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 lukaswhite/podcast-feed-validator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 459
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-07