PHPackages                             testflowlabs/doctest - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. testflowlabs/doctest

ActiveLibrary[Testing &amp; Quality](/categories/testing)

testflowlabs/doctest
====================

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

v1.10.0(3mo ago)46.1k↓88.9%1MITPHPPHP ^8.4CI passing

Since Feb 6Pushed 3mo agoCompare

[ Source](https://github.com/TestFlowLabs/doctest)[ Packagist](https://packagist.org/packages/testflowlabs/doctest)[ RSS](/packages/testflowlabs-doctest/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (7)Versions (14)Used By (1)

 [![DocTest](docs/public/doctest-logo.svg)](docs/public/doctest-logo.svg)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?
----

[](#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
------------

[](#installation)

```
composer require --dev testflowlabs/doctest
```

Quick Start
-----------

[](#quick-start)

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

```
```php
echo 'Hello, World!';
```

```

Run it:

```
vendor/bin/doctest
```

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

What Can It Do?
---------------

[](#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](https://doctest.testflowlabs.dev/)**.

Requirements
------------

[](#requirements)

- PHP 8.4+

License
-------

[](#license)

MIT

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance80

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

13

Last Release

106d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3030815?v=4)[Yunus Emre Deligöz](/maintainers/deligoez)[@deligoez](https://github.com/deligoez)

---

Top Contributors

[![deligoez](https://avatars.githubusercontent.com/u/3030815?v=4)](https://github.com/deligoez "deligoez (659 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/testflowlabs-doctest/health.svg)

```
[![Health](https://phpackages.com/badges/testflowlabs-doctest/health.svg)](https://phpackages.com/packages/testflowlabs-doctest)
```

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k532.1M19.4k](/packages/laravel-framework)[helsingborg-stad/municipio

A bootstrap theme for creating municipality sites.

4028.3k10](/packages/helsingborg-stad-municipio)[testo/testo

A lightweight PHP testing framework.

1923.4k32](/packages/testo-testo)[chameleon-system/chameleon-base

The Chameleon System core.

1027.9k4](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
