Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Shiki Php Laravel Package

spatie/shiki-php

Use Shiki syntax highlighting from PHP. Highlight code snippets with editor-quality themes and 100+ languages, plus Antlers and Blade. Works great with Laravel via spatie/laravel-markdown and CommonMark through a companion extension.

View on GitHub
Deep Wiki
Context7

Highlight code using Shiki in PHP

Frequently asked questions about Shiki Php
How do I install spatie/shiki-php in a Laravel project?
Run `composer require spatie/shiki-php` to install the package. Ensure your server has Node.js v18+ installed, as Shiki relies on a JavaScript runtime. No additional Laravel service provider or config is needed—just call `Shiki::highlight()` directly.
Does spatie/shiki-php work with Laravel Blade templates?
Yes, the package includes Blade as a supported language. Highlight Blade snippets by passing `'blade'` as the language parameter, e.g., `Shiki::highlight($code, 'blade', 'github-dark')`. It’s ideal for embedding syntax-highlighted Blade examples in documentation.
Can I use custom themes with spatie/shiki-php?
Yes, Shiki v4 supports custom themes, and the PHP wrapper exposes this via the `theme` parameter. Check the [Shiki themes documentation](https://github.com/shikijs/shiki/tree/main/docs/themes.md) for available themes or use your own. The package also supports the new 'dual themes' feature for more flexibility.
Will this work in Laravel Forge or shared hosting environments?
It depends on Node.js availability. Forge environments typically include Node.js, but shared hosting often restricts it. Test your hosting provider’s Node.js support first. If unavailable, consider alternatives like Highlight.js or offload highlighting to a microservice.
How do I integrate spatie/shiki-php with spatie/laravel-markdown?
Install both packages (`spatie/laravel-markdown` and `spatie/shiki-php`), then configure the Markdown parser to use Shiki’s highlighter. The `laravel-markdown` package automatically detects and uses `shiki-php` if installed, so no extra setup is required for basic usage.
What Laravel versions are supported by spatie/shiki-php?
The package is framework-agnostic but works seamlessly with Laravel 8.x, 9.x, and 10.x. It requires PHP 8.1+. No Laravel-specific dependencies exist beyond Node.js, so it’s compatible as long as your app meets those requirements.
Is there a performance impact when using spatie/shiki-php in production?
Yes, Shiki spawns a Node.js process for each highlight call, which introduces IPC overhead. For high-traffic sites, cache highlighted snippets (e.g., in Redis) or use a queue system to batch requests. Test with your expected load to gauge latency.
How do I highlight code in CommonMark/Markdown using this package?
Use the companion package `spatie/commonmark-shiki-highlighter`. Install it via Composer, then configure your CommonMark parser to use the Shiki highlighter. It automatically handles Markdown code blocks with syntax highlighting, including fenced code blocks.
Are there alternatives to spatie/shiki-php for PHP-only environments?
Yes, if Node.js isn’t available, consider **Highlight.js** (pure PHP wrappers exist) or **Prism.js** with a PHP wrapper. These are less feature-rich than Shiki but avoid Node.js dependencies. For Laravel, `spatie/laravel-markdown` also supports Highlight.js as a fallback.
How do I handle Shiki v4 breaking changes in my Laravel app?
Test thoroughly with your most complex syntax (e.g., Blade, Antlers, or rare languages). The PHP wrapper abstracts most changes, but validate output consistency. If using custom themes, update them to Shiki v4’s format. Refer to the [Shiki migration guide](https://github.com/shikijs/shiki/blob/main/docs/migration.md) for specifics.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai