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 Bundle

Highlight Bundle Laravel Package

nicodmf/highlight-bundle

Symfony bundle that integrates highlight.php to add syntax highlighting for code snippets. It provides Twig helpers and configurable themes, making it easy to render readable, colorized source code in templates with minimal setup.

View on GitHub
Deep Wiki
Context7

This bundle transforms a part of text representing a source code in html formated text, providing 5 highlighter: pygment, geshi, highlight, http request to appspot, http request to hiliteme

Frequently asked questions about Highlight Bundle
Can I install nicodmf/highlight-bundle in a Laravel application?
No. nicodmf/highlight-bundle is a Symfony bundle, not a Laravel package: it ships Bundle-class scaffolding, DI extension and config loaders, and a Twig extension that hook into Symfony kernel and container integration points Laravel does not have. Running composer require against a Laravel 10 or 11 app is expected to fail or produce dependency conflicts. Treat the repository as a design specification for "highlight code inside a template" and re-implement the small service contract natively.
Does nicodmf/highlight-bundle support Laravel 10, Laravel 11, or PHP 8?
There is no Laravel support of any kind, and the codebase is PHP 5.x-era Symfony2 with no scalar types and pre-PSR-4 assumptions. Symfony2 has been end-of-life since 2018, so you should assume the package is incompatible with PHP 8 runtimes. Any Laravel integration would require a full rewrite rather than a patch, so plan for a native implementation instead.
How do I add server-side syntax highlighting to Laravel without client-side JavaScript?
Bind a Highlighter contract in a HighlighterServiceProvider, implement it once against a pure-PHP engine such as scrivo/highlight.php, and expose the result through a Blade directive or anonymous component. Add a config/highlight.php file for the engine, theme, and options, and wrap the engine in a caching decorator so rendering is not repeated per request. The result is render-time highlighted HTML with no runtime JS dependency.
What is the Laravel equivalent of this bundle's Twig filter?
Use a Blade directive such as @highlight($code, 'php') or an anonymous component like <x-code lang="php">{{ $snippet }}</x-code>. Both call the same injected highlighter service, so the template-facing API stays as convenient as the original Twig filter. Keep the directive thin and put engine selection, theming, and caching behind the interface.
Should I use scrivo/highlight.php, Pygments, or Shiki as the highlighting engine?
scrivo/highlight.php is pure PHP, so it carries the lowest deployment risk and removes any system binary requirement, making it the sensible default. Pygments or GNU highlight shelled out via Laravel's Process facade give the best fidelity for exotic languages but add argument-injection, unbounded-input, and subprocess-timeout concerns. Shiki runs at build time in Node, which is ideal if highlighting can be baked in on write rather than per request.
Is highlighted HTML from a server-side highlighter safe to render unescaped in Blade?
Rendering highlighter output unescaped is a stored-XSS vector for any untrusted snippet, because the markup is injected directly into the page. Only skip Blade escaping for trusted, curated sources such as internal docs or changelogs; for user submissions or PR diffs, sanitize the output or keep it escaped. Remember the markup is engine-specific, so the engine choice silently becomes a rendering contract that is expensive to change later.
How should I cache highlighted code in Laravel?
Put a caching decorator in front of your Highlighter contract and use Cache::remember keyed by a hash of the code, language, theme, and engine version. This is mandatory if you shell out to an external binary, because per-request subprocess spawning rarely fits a latency budget. Caching also makes the per-request cost predictable during traffic spikes.
Is nicodmf/highlight-bundle actively maintained and safe to depend on?
No. It has roughly 21 stars and zero dependents, so there is no user base to surface defects, no upstream patch path, and no security response capability. Adopting it means you become the first production user and the de facto maintainer. Fork the pattern or write the few hundred lines yourself rather than taking the dependency.
How do I test a syntax highlighter integration in a Laravel package?
Avoid asserting exact markup and CSS classes, because those change whenever the engine or theme is upgraded and will make your suite brittle. Instead assert that input is escaped correctly, that the requested language is dispatched to the right driver, and that unknown languages fall back gracefully. If you shell out, add tests for subprocess timeouts and oversized input, and use one snapshot test per supported language.
What are the alternatives to nicodmf/highlight-bundle for a Laravel project?
For render-time highlighting, bind scrivo/highlight.php behind your own contract, or use a Shiki-based solution such as spatie/laravel-markdown if build-time highlighting is acceptable. Pygments through the Process facade remains the fallback when a required language is unsupported in pure PHP. If you only need highlighting inside Markdown rendering, a CommonMark extension is lighter than a dedicated highlighter service.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
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