Other PHP CLI tool can communicate with API using JSON. Why not PHPUnit?
This package requires PHPUnit 10+ and PHP 8.1+.
composer require --dev tomasvotruba/phpunit-json-result-printer
Register extension in your phpunit.xml
file:
<extensions>
<bootstrap class="TomasVotruba\PHPUnitJsonResultPrinter\PHPUnitJsonResultPrinterExtension" />
</extensions>