PHPackages                             bakgul/laravel-tests-to-readme - 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. bakgul/laravel-tests-to-readme

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

bakgul/laravel-tests-to-readme
==============================

A package to output test methods to readme files as a documantation.

v1.0.2(3y ago)141PHP

Since Feb 7Pushed 3y ago1 watchersCompare

[ Source](https://github.com/bulentAkgul/laravel-tests-to-readme)[ Packagist](https://packagist.org/packages/bakgul/laravel-tests-to-readme)[ RSS](/packages/bakgul-laravel-tests-to-readme/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Laravel Tests To Readme
=======================

[](#laravel-tests-to-readme)

This package aims to generate readme files while tests are being executed. To make this work, you need to call it inside a test method. So, it won't convert each and every test methods to readme file automatically.

### Installation and Configuration

[](#installation-and-configuration)

```
sail composer require bakgul/laravel-tests-to-readme --dev

```

```
sail artisan vendor:publish --tag=to-readme-config

```

Now, you can go and change the settings after publishing config file, which is 'to-readme.php'

Finally, we need a folder to store readme files. You can name it as you wish, but it has to be located under one of the folder of the test class path. For example, if your test class is in

`base_path('tests/Feature/EndpointTests/UserEndpointTests')`

then you can create a folder in

`base_path()` or `base_path('tests')` or `base_path('tests/Feature')` etc.

### Some Notes

[](#some-notes)

1. I suggest you keep readme folder on the root level. That being said, each file will be named based on the testing class. So, if you have multiple classes with the same name, you can't use `base_path('readme')` for all of them. In that case, you may want to create multiple readme folders.
2. This package doesn't produce final `README.md` file. You need to create it manually.
3. When you add a new test with a call to this package, your new method will be added to the target file.
4. You can modify the output because it won't be overwritten once it's being printed out.
5. When you rename a test method, it will be added to the target file. But you need to delete the old one manually.
6. You can add paragraph, lists, tables in between code blocks. They will be preserved.

### How It Works

[](#how-it-works)

You should call this package in your test method.

```
class MyClassTest extends TestCase
{
    /** @test */
    public function my_test_method_does_things(): void
    {
        (new ToReadme([
            'test' => $this->getName();
            'class' => MyClass::class,
            'method' => 'doSomething',
            'args' => [1, 2],
            'message' => 'Anything you want to print.',
            'result' => 3
        ]))->write();

        // Your test ...
    }
}
```

The code above will generate a `readme/MyClass.md` file and put the content like between the horizontal lines down below.

---

### MyClass

[](#myclass)

#### doSomething

[](#dosomething)

```
/**
 * If you have Phpdoc, it will be displated here
 */
public function doSomething(int $num1, int $num2): int

```

```
// My test method does things.

// Anything you want to print.

(new MyClass)->doSomething(1, 2);

// 3
```

---

As you may have noticed, we passed a value as result, and it's printed in the code block. I suggest you do this way, but you don't have to specify the outcome of the method. When the key of "result" doesn't exist, we will try to execute the method and produce the outcome to print.

### Phpdoc vs Typehint

[](#phpdoc-vs-typehint)

This package can use both to produce file. If you make `merge_phpdoc_and_method_declaration => true`, we will move types from phpdoc to typehint. Otherwise, we won't change anything.

The method down below

```
/**
 * It does some stuff
 *
 * @param array $arr
 * @param int   $int
 * @return array
 */
 public function do($arr, $int) { return [$arr, $int]; }
```

will be printed like this:

```
/**
 * It does some stuff
 */
 public function do(array $arr, int $int): array
```

When you use both, and there is an inconsistency between phpdoc and typehints, a warning message will be printed. The method down below

```
/**
 * It does some stuff
 *
 * @param array $arr
 * @return array
 */
 public function do(array|string $arr) { return $arr; }
```

will be printed like this:

```
WARNINGS:
   - mismatched types.

/**
 * It does some stuff
 */
 public function do(array $arr, int $int): array
```

There are other inconsistency checks, too. You can find them in `to-readme.php`

### Some Limitations

[](#some-limitations)

1. As it's mentioned before, when you don't pass 'result,' we will try to call the method and get the output. If the class has dependencies, it will probably won't work. In such cases, you better specify the result manually.
2. The array returned by the method will be converted to Json string and then modifyed through some character replacements to make it looks like a PHP array. It might not turn out well in all cases.
3. Identifier heading levels cannot be used anywhere else in readme.
4. First line that starts with '//' has to be the name of the test method.
5. I couldn't find any way to print out the callable arguments. So, you need to add them manually.

License
-------

[](#license)

This is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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 ~8 days

Total

3

Last Release

1175d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dc3c26b9029d2705ffcd2baebee543db52c24b1fb5cb29c5557436de853d42c1?d=identicon)[bulentAkgul](/maintainers/bulentAkgul)

---

Top Contributors

[![bulentAkgul](https://avatars.githubusercontent.com/u/12589023?v=4)](https://github.com/bulentAkgul "bulentAkgul (7 commits)")

### Embed Badge

![Health badge](/badges/bakgul-laravel-tests-to-readme/health.svg)

```
[![Health](https://phpackages.com/badges/bakgul-laravel-tests-to-readme/health.svg)](https://phpackages.com/packages/bakgul-laravel-tests-to-readme)
```

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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