Phiki is a syntax highlighter by Ryan Chandler written in PHP. It uses TextMate grammar file format and Visual Studio Code themes to generate syntax-highlighted code for the web and terminal. Here's an example of the API you can use to pass in a code snippet, language, and theme:
use Phiki\Phiki;use Phiki\Grammar\Grammar;use Phiki\Theme\Theme; $phiki = new Phiki(); echo $phiki->codeToTerminal( <<<'PHP' use Illuminate\Support\Facades\Route; Route::get('/', function () { return view('welcome'); }); PHP, Grammar::Php, Theme::GithubDark,); echo "\n\n";
The results can be output to the terminal with styling matching the selected theme:

Using the codeToHtml()
method, Phiki will return the HTML code (with inline styles) required to display the snippet in HTML. Phiki also supports line numbers, multi-theme support, and more:

Main Features
- TextMate Grammar Integration: Utilizes TextMate grammar files
- Visual Studio Code Theme Support: Applies Visual Studio Code themes for code highlighting
- Extensive Language and Theme Coverage: Over 200 language grammars and more than 50 themes
- Web and Terminal Output: Generates syntax-highlighted code for both web and terminal
- CommonMark Integration: Start using Phiki on your blog or documentation site with very little effort
Learn more about this package, get full installation instructions, and view the source code on GitHub.