PHPackages                             shikiphp/shikiphp - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. shikiphp/shikiphp

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

shikiphp/shikiphp
=================

Pure PHP port of Shiki. Syntax-highlight code with VS Code themes and TextMate grammars — no extensions, no Node, no Oniguruma binding.

v0.1.0(1mo ago)01MITPHPPHP ^8.2CI passing

Since Jun 23Pushed 2w agoCompare

[ Source](https://github.com/inline0/shikiphp)[ Packagist](https://packagist.org/packages/shikiphp/shikiphp)[ Docs](https://github.com/inline0/shikiphp)[ RSS](/packages/shikiphp-shikiphp/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

    ![shikiphp](./docs/public/logo-light.svg)

 Pure PHP syntax highlighter — a port of Shiki. Style code blocks with VS Code themes and TextMate grammars, in PHP only.

 [![CI](https://github.com/inline0/shikiphp/actions/workflows/ci.yml/badge.svg)](https://github.com/inline0/shikiphp/actions/workflows/ci.yml) [![Packagist](https://camo.githubusercontent.com/ab911a8f143e149c80a3314e556f4e90648a1e458267f7aefbf021dfbd3272ad/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7368696b697068702f7368696b697068702e737667)](https://packagist.org/packages/shikiphp/shikiphp) [![license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://github.com/inline0/shikiphp/blob/main/LICENSE)

---

What is shikiphp?
-----------------

[](#what-is-shikiphp)

shikiphp is a pure PHP port of [Shiki](https://shiki.style), the syntax highlighter that powers VS Code's own coloring. It tokenizes code with the same **TextMate grammars** and paints it with the same **VS Code themes** Shiki uses, producing identical HTML — entirely in PHP.

**The problem:** server-rendered syntax highlighting in PHP usually means either shelling out to Node, calling a hosted API, or settling for a regex-based highlighter that doesn't understand the language. None of those are great for a Laravel/WordPress/static-site build step.

**shikiphp solves this** by porting Shiki's real pipeline to PHP:

- TextMate grammar tokenizer (a faithful port of `vscode-textmate`), incl. embedded languages, injections, and nested repositories
- VS Code theme resolution with scope-selector specificity (`vscode-textmate`'s theme matching)
- A pure-PHP **JavaScript regex engine** as the grammar regex runtime, fed by an `oniguruma-to-es` port — the same Oniguruma→RegExp path modern Shiki uses
- Shiki-compatible HTML output: dual light/dark themes via CSS variables, `codeToHast`, transformers (all hooks), decorations, `colorReplacements`, `structure: inline`, and ANSI (`lang: 'ansi'`) highlighting
- the **full Shiki bundle** — every `tm-grammars` language (200+) and `tm-themes` theme (65)
- No PHP extensions beyond `json`/`mbstring`, no Node, no native Oniguruma binding
- Validated token-for-token against Shiki.js with an oracle regression harness (scenarios across the full grammar/theme set)

Quick Start
-----------

[](#quick-start)

```
composer require shikiphp/shikiphp
```

```
use Shikiphp\Shikiphp;

echo Shikiphp::codeToHtml(
