krystal-sf / ux-prism
Prism Js Integration for Krystal Symfony Projects
Requires
- php: ^8.1
- krystal-sf/plugin-manager: ^1.0
- krystal-sf/ux-common: ^1.0
Requires (Dev)
- badpixxel/php-sdk: ^3.0
- krystal-sf/ux-menus: ^1.0
- krystal-sf/ux-metadata: ^1.0
- symfony/debug-bundle: ^6.4|^7.4|^8.0
- symfony/monolog-bundle: ^3.0|^4.0
- symfony/stopwatch: ^6.4|^7.4|^8.0
- symfony/web-profiler-bundle: ^6.4|^7.4|^8.0
This package is auto-updated.
Last update: 2026-08-05 09:30:11 UTC
README
Prism Js integration for Krystal Symfony UX Projects: code highlighting as a Twig Component, with automatic JSON reformatting.
Installation
composer require krystal-sf/ux-prism
This bundle is a Krystal Plugin (krystal-sf/plugin-manager) — the
recommended way to enable it is through the Plugin Manager:
bin/console plugin:discover
bin/console plugin:enable ksf_prism_js
Alternatively, register it as a regular bundle in config/bundles.php:
return [
// ...
Ksf\Plugins\PrismJs\KsfPrismJsBundle::class => ['all' => true],
];
Then import the loader once in your assets/app.js:
import "@krystal-sf/ux-prism";
Usage
<twig:PrismJs:Code language="php" :code="mySourceCode" />
Highlighting runs on DOMContentLoaded and re-runs automatically on DOM
mutations (Live Components re-renders) via a MutationObserver.
JSON contents are pretty-printed with JSON.stringify before highlight
when the received string is raw.
NB: additional languages are fetched on demand by the Prism autoloader from the jsDelivr CDN.
License
MIT — see LICENSE.