afragen/wp-readme-parser
Composer 安装命令:
composer require afragen/wp-readme-parser
包简介
A PHP library for parsing WordPress plugin readme.txt files into structured data.
README 文档
README
A PHP library for parsing WordPress plugin readme.txt files into structured data,
with no WordPress dependencies.
Requirements
- PHP 8.0 – 8.5
- Composer
Installation
composer require fragen/wp-readme-parser
Usage
use Fragen\WP_Readme_Parser\Parser; // From a file path $parser = new Parser('/path/to/readme.txt'); // From a URL $parser = new Parser('https://plugins.svn.wordpress.org/my-plugin/trunk/readme.txt'); // From a raw string $parser = new Parser($readmeContents);
Parsed properties
The parser exposes the same public properties as the official WordPress.org readme parser, making it a drop-in replacement for subclassing.
| Property | Type | Description |
|---|---|---|
$name |
string|false |
Plugin name. false if the name header was absent or used the placeholder value. |
$tags |
array |
Up to 5 tags (ignored tags and extras are dropped with warnings). |
$requires |
string |
Minimum WordPress version, e.g. "6.0". |
$tested |
string |
Tested-up-to version. |
$requires_php |
string |
Minimum PHP version. |
$contributors |
string[] |
Contributor slugs (format-validated). |
$stable_tag |
string |
Stable tag / version string. |
$donate_link |
string |
Donation URL (http/https only). |
$license |
string |
License identifier. |
$license_uri |
string |
License URL. |
$short_description |
string |
Plain-text short description, max 150 characters. |
$sections |
array |
Rendered HTML sections keyed by name: description, installation, faq, changelog. |
$faq |
array |
FAQ entries keyed by question string, values are rendered HTML. |
$screenshots |
array |
Screenshot captions, 1-based integer keys. |
$upgrade_notice |
array |
Upgrade notices keyed by version string. |
$warnings |
array |
Parsing anomaly flags — see below. |
$raw_contents |
string |
Unmodified input. |
Warning keys
| Key | Meaning |
|---|---|
invalid_plugin_name_header |
Name header was missing or used the Plugin Name placeholder. |
ignored_tags |
Tags removed because they appear in the ignore list (plugin, wordpress). |
too_many_tags |
More than 5 tags supplied; extras dropped. |
contributor_ignored |
One or more contributor slugs had an invalid format and were dropped. |
requires_php_header_ignored |
Requires PHP value was not a valid x.y[.z] version string. |
requires_header_ignored |
Requires at least value could not be parsed as a version. |
tested_header_ignored |
Tested up to value could not be parsed as a version. |
license_missing |
No License header was found. |
invalid_license |
License appears to be incompatible with WordPress directory guidelines. |
unknown_license |
License could not be identified as compatible or incompatible. |
no_short_description_present |
Short description was inferred from the description section body. |
trimmed_short_description |
Short description was truncated to 150 characters. |
trimmed_section_* |
A section was truncated to its word limit (2 500 general; 5 000 for changelog and faq). |
Dependency injection
The sanitizer and Markdown converter are both injectable:
use Fragen\WP_Readme_Parser\Contracts\HtmlSanitizerInterface; use Fragen\WP_Readme_Parser\Contracts\MarkdownConverterInterface; $parser = new Parser( input: $readmeContents, sanitizer: $myCustomSanitizer, // implements HtmlSanitizerInterface markdown: $myCustomConverter, // implements MarkdownConverterInterface );
Differences from a WordPress-native environment
| Area | This library | WordPress-native |
|---|---|---|
| HTML sanitization | Native DOMDocument (NativeHtmlSanitizerAdapter) |
wp_kses() |
| Markdown | erusev/parsedown |
Internal WP.org Markdown class |
| Contributor validation | Slug format check only | Live get_user_by() WP DB query |
Tested up to upper bound |
Not enforced | Capped at WP_CORE_STABLE_BRANCH + 0.1 |
| WordPress dependency | None | Required |
Running tests
composer install ./vendor/bin/phpunit # all tests ./vendor/bin/phpunit --testsuite Unit # unit tests only ./vendor/bin/phpunit --testsuite Integration # real-adapter tests only composer stan # PHPStan static analysis composer cs # check code style composer cs:fix # fix code style
License
MIT © Andy Fragen
afragen/wp-readme-parser 适用场景与选型建议
afragen/wp-readme-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 afragen/wp-readme-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 afragen/wp-readme-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 10
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 33
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-10