Introducing a small library I wrote over the weekend which prints syntax highlighted (colored) PHP code into the terminal.
You can use it in any PHP CLI applications to pretty print PHP code OR to take screenshot of code and use somewhere.
Right now screenshot is manual process but it will soon be automated into this library so you can save a PNG image of your code.
Installation
$ composer require adhocore/cli-syntax
Usage
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');
adhocore / php-cli-syntax
PHP Code Syntax Highlighter and/or exporter for CLI. Zero Dependency.
adhocore/cli-syntax
_ _ _
___ | | (_) ___ | |__
/ __| | | | | / __| ' _ \
| (__ | | | | \___ \ | | | |
\___| |_| |_| |____/ |_| |_|
PHP CLI Syntax Highlight Tool
=============================
Installation
As phar binary
curl -SsLo ~/clish.phar https://github.com/adhocore/php-cli-syntax/releases/latest/download/clish.phar
chmod +x ~/clish.phar && sudo ln -s ~/clish.phar /usr/local/bin/clish
Follow same steps to upgrade.
As standalone binary
composer global require adhocore/cli-syntax
Follow same steps to upgrade.
As project dependency
composer require adhocore/cli-syntax
Usage
Shell command
If you installed as binary following any of the above methods, 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.png
clish
stands for CLI syntax highlight.
Options
Parameter options:
[-e|--echo] Forces echo to
…Feedbacks and contributions are welcome. Thank you.
Top comments (1)
I use Vim syntax highlighter.