testflowlabs/doctest 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

testflowlabs/doctest

最新稳定版本:v1.10.0

Composer 安装命令:

composer require testflowlabs/doctest

包简介

A PHP documentation testing tool that validates code examples in markdown files

README 文档

README

DocTest

DocTest

A PHP documentation testing tool that validates code examples in your markdown files. Write documentation with confidence — if it compiles and runs, it stays correct.

Why?

Code examples in documentation rot. APIs change, methods get renamed, return types evolve — but the docs stay frozen. DocTest extracts PHP code blocks from your markdown files, executes them in isolated processes, and verifies their output. If an example breaks, you'll know immediately.

  • Tested documentation — code examples are verified on every CI run
  • Invisible assertions — HTML comments keep assertions hidden from rendered docs
  • Shiki compatible — handles // [!code hide], diff markers, highlights, and all Shiki annotations
  • Process isolation — each example runs in its own process, no side effects
  • Zero setup — run vendor/bin/doctest and it just works

Installation

composer require --dev testflowlabs/doctest

Quick Start

Write a PHP code block in any markdown file with an assertion in an HTML comment:

```php
echo 'Hello, World!';
```
<!-- doctest: Hello, World! -->

Run it:

vendor/bin/doctest

DocTest scans docs/ and README.md by default. That's it.

What Can It Do?

DocTest supports six assertion types, wildcards for dynamic output, code block attributes (ignore, no_run, throws, parse_error, setup, teardown), grouped examples with shared state, a bootstrap config for loading your project's autoloader, and bootstrap profiles for per-block environments via the .doctest/ directory. A few examples:

echo 2 + 3;
$prices = [10.5, 20.0, 30.75];
$total = array_sum($prices); // => 61.25
echo json_encode(['tool' => 'DocTest']);

For the full feature set — assertions, attributes, wildcards, groups, configuration, CLI options, CI integration, and framework bootstrap — see the Documentation.

Requirements

  • PHP 8.4+

License

MIT

统计信息

  • 总下载量: 6.06k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-02-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固