Skip to content

PHP Code Syntax Highlighter and/or exporter for CLI. Zero Dependency.

License

Notifications You must be signed in to change notification settings

adhocore/php-cli-syntax

 
 

Repository files navigation

adhocore/cli-syntax

Latest Version Travis Build Scrutinizer CI Codecov branch StyleCI Software License

Installation

As standalone binary

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.png

As project dependency

composer require adhocore/cli-syntax

Usage

You can either highlight PHP code in terminal output or export to png image.

Highlight

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');

Export

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:

adhocore/cli-syntax

Customisation

If you would like to change color etc, extend the classes Highlighter and Exporter, then override visit() method which recieves DOMNode.

Contributing

Please check the guide.

LICENSE

© MIT | 2019, Jitendra Adhikari

Credits

This project is bootstrapped by phint and releases managed by please.

Sponsor this project

  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages