Weave 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

Highlight Laravel Package

tempest/highlight

Tempest Highlight is a fast, extensible, server-side code highlighting library for PHP. Highlight code in any language with a simple API, no client-side JavaScript required. Install via Composer and start parsing immediately.

View on GitHub
Deep Wiki
Context7

tempest/highlight is a fast, extensible, server-side code highlighting library for PHP. It parses source code and returns syntax-highlighted HTML, letting you render beautiful code snippets without relying on client-side JavaScript. Simply install via Composer, instantiate the Highlighter, and call parse($code, 'php') to get started.

  • Server-side rendering — no JavaScript required
  • Extensible architecture — add custom languages and themes
  • Simple API — one method to highlight any snippet
  • Fast performance — lightweight and efficient parsing
Frequently asked questions about Highlight
How do I install and use tempest/highlight in Laravel?
Install with Composer using composer require tempest/highlight, then instantiate the Highlighter class and call parse with your code and language. In Laravel you can resolve or instantiate the highlighter in a controller, Blade view, or service class. The package is pure PHP and does not require client-side JavaScript.
Does tempest/highlight work with Laravel Blade templates?
Yes. You can call the highlighter from a Blade template and output the highlighted HTML, for example by passing code and a language name to the parse method. Since highlighting happens server-side, Blade views do not need Prism.js or Highlight.js. Make sure you trust or sanitize the source code before outputting raw HTML.
Which languages does tempest/highlight support?
It supports many common languages and the evaluation notes 30+ supported languages, including PHP. Language support is extensible through custom parsers, so you可以 add niche or internal formats when needed. Check the documentation for the current language list before committing to a specific language.
Can tempest/highlight be used for API responses and JSON endpoints?
Yes. You can call the highlighter in a controller or service and include the highlighted HTML string in a JSON response for SPAs, mobile apps, or documentation APIs. Because it runs server-side, API consumers do not need a client-side highlighting library. Cache repeated snippets if the same code blocks are returned often.
How do I create a custom theme with tempest/highlight?
The package supports pre-built themes and custom themes, including CSS variable-based styling. You typically define theme styles or override CSS variables to match your brand, then pass the theme to the highlighter as documented. This lets you keep highlighting consistent with your application without extra frontend styling work.
Is tempest/highlight faster than Prism.js or Highlight.js?
tempest/highlight is designed for fast server-side highlighting and uses benchmark-driven optimizations. It removes client-side JavaScript parsing from the browser, which can reduce bundle size and improve page load performance. Actual speed depends on language, code size, caching, and whether you compare server render time with browser render time. Benchmark your own snippets for a fair comparison.
Can I cache highlighted code snippets in Laravel with tempest/highlight?
Yes. Highlighted output is a string, so you can cache it with Laravel's cache system, Redis, or any cache store keyed by code hash, language, and theme. Caching is especially useful for static documentation or repeated code examples. Invalidate the cache when the code, language, theme, or package version changes.
How do I add support for a custom or unsupported language in tempest/highlight?
The highlighter is extensible and supports custom language parsers or plugins for niche DSLs and proprietary formats. You can build an extension for the missing syntax and register it with the highlighter. If the language is broadly useful, consider contributing it back to the Tempest project.
Does tempest/highlight support terminal or CLI output?
Yes. The package is described as server-side code highlighting for web and terminal, so it can be used in CLI tools and Laravel commands as well as web views. Terminal output may use different formatting than HTML, so check the documentation for terminal-specific usage. It can be useful for Telescope-like interfaces or internal developer tools.
What are the alternatives to tempest/highlight for server-side syntax highlighting in Laravel?
Alternatives include client-side libraries such as Prism.js and Highlight.js, or other PHP highlighting packages, but those may add JavaScript or different integration tradeoffs. tempest/highlight is attractive when you want pure PHP rendering, Blade integration, custom themes, and no client-side dependency. Evaluate language support, theming, caching needs, and maintenance before choosing.
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.
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core