composer global require adhocore/cli-syntax
# then you will be able to run it as
clish -h
clish -f file.php
echo '<?php date("Ymd");' | clish
cat file.php | clish
# export png
clish -f file.php -o file.pngcomposer require adhocore/cli-syntaxYou can either highlight PHP code in terminal output or export to png image.
use Ahc\CliSyntax\Highlighter;
// PHP code
echo new Highlighter('<?php echo "Hello world!";');
// OR
echo (new Highlighter)->highlight('<?php echo "Hello world!";');
// PHP file
echo Highlighter::for('/path/to/file.php');use Ahc\CliSyntax\Exporter;
// PHP file
Exporter::for('/path/to/file.php')->export('file.png');See example usage. Here's how the export looks like:
If you would like to change color etc, extend the classes
Highlighter and Exporter,
then override visit() method which recieves DOMNode.
Please check the guide.
© MIT | 2019, Jitendra Adhikari
This project is bootstrapped by phint and releases managed by please.
