PHP code example of adhocore / cli-syntax

1. Go to this page and download the library: Download adhocore/cli-syntax library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

adhocore / cli-syntax example snippets


use Ahc\CliSyntax\Highlighter;

// PHP code
echo new Highlighter(' echo "Hello world!";');
// OR
echo (new Highlighter)->highlight(' echo "Hello world!";', $options);

// PHP file
echo Highlighter::for('/path/to/file.php', $options);

// $options array is optional and can contain:
[
    'lineNo' => true, // bool
];

use Ahc\CliSyntax\Exporter;

// PHP file
Exporter::for('/path/to/file.php')->export('file.png', $options);

// $options array is optional and can contain:
[
    'lineNo' => true, // bool
    'font'   => 'full/path/of/font.ttf', // str
    'size'   => 'font size', // int
];
sh
# you will be able to run it as
clish -h
clish -f file.php
echo ' date("Ymd");' | clish
cat file.php | clish

# export png
clish -f file.php -o file.png