PHP Code Syntax highlighting (pretty printing) for CLI.

Jitendra - Dec 23 '19 - - Dev Community

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

GitHub logo adhocore / php-cli-syntax

PHP Code Syntax Highlighter for CLI

adhocore/cli-syntax

Latest Version Travis Build Scrutinizer CI Codecov branch StyleCI Software License

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

See example. Here's the screenshot too:

adhocore/cli-syntax

Contributing

Please check the guide.

LICENSE

© MIT | 2019, Jitendra Adhikari

Credits

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

Feedbacks and contributions are welcome. Thank you.

. . . . . . . . . . . . . . . . . . .
Terabox Video Player