torchlight/engine
Torchlight Engine is a standalone PHP syntax highlighting engine built on TextMate grammars and VS Code themes. It renders accurate, themeable code blocks without Node.js or client-side JavaScript, and powers Torchlight's Laravel package while working in any PHP project.
Architecture fit. torchlight/engine is the PHP-side rendering core of the Torchlight annotation system. Architecturally it is a strong fit for a Laravel monolith because it lets code highlighting and annotation run in-process rather than round-tripping code to the hosted Torchlight API. That is the central architectural value: it removes a third-party network hop, eliminates sending source snippets off-premises, and decouples rendering cost from API quotas. It is not a general-purpose highlighter (it is not a replacement for spatie/laravel-markdown or league/commonmark); it is purpose-built for the Torchlight annotation syntax (line highlighting, diffs, focus ranges, labels). v1.0.0 resolves the biggest open architectural question in the prior assessment: "Phiki 2 Support" confirms the engine is a wrapper over Phiki, the pure-PHP port of Shiki. That means TextMate grammars and themes are consumed in PHP with no Node or WASM runtime — the materially better operational story we hoped for. It also means the engine inherits Phiki's grammar/theme fidelity characteristics and Phiki's release cadence.
Integration feasibility. Composer-installable, MIT-licensed, now at a stable 1.0.0. The 1.0.0 designation is the headline change: it implies a semver contract and an end to arbitrary API churn, which was previously an explicit risk. Feasibility friction now shifts almost entirely to the dependency graph. The release notes bundle two distinct things — reaching 1.0.0 and adopting Phiki 2 — and we cannot tell from the notes whether Phiki 1 is still supported via a widened constraint or has been dropped. That single fact determines whether this is a routine upgrade or a forced migration for anyone already pinned.
Technical risk. The prior risk profile changes meaningfully, in both directions:
torchlight/torchlight-laravel client planning to consume it.torchlight/engine is unchanged, which directly threatens our rendered-HTML parity.Key questions to resolve before committing.
<span> nesting)? This is the single highest-value thing to test, because it is exactly what our parity harness checks.torchlight/torchlight-laravel client, or still a parallel API we must wire up ourselves?Stack fit. Laravel + Composer, auto-discovered provider, config-published defaults. The engine plausibly slots in beneath the existing Torchlight Blade directive / Markdown extension surface, so application code using torchlight fences should not need to change. If it does require application-level changes, treat that as a scoping surprise and re-evaluate. Add Phiki to the stack-fit review as a first-class component, not an invisible transitive: its version, its grammar/theme sourcing, and its maintainership now matter to us.
Migration path. The realistic migration is still from the hosted API to local rendering, but the sequencing now has an important refinement — upgrade and adoption are two separable decisions and should be evaluated separately:
torchlight/torchlight-laravel version and capture baseline rendered HTML for a representative corpus (docs pages, blog posts, README renders, changelog diffs). Include deliberately awkward blocks: long lines, nested lists, diffs, focus ranges, non-ASCII, unknown languages.torchlight/engine 1.0.0 on a feature branch and check only whether the lockfile resolves. Confirm which Phiki major it pulls and whether that conflicts with anything already in the graph.engine or to Phiki 2 where you can — it tells us who to file upstream with and where our fork contingency would live.Compatibility. Verify the Composer constraint graph against our lockfile first — a transitive PHP, illuminate/*, or Phiki conflict is the most likely blocker and is cheap to check before any engineering time is spent. Specifically determine whether the engine now pins phiki/phiki:^2 and whether that collides with anything else in our graph that also uses Phiki. Also confirm whether the engine and the current hosted-API client can coexist (dual-path rollout) or are mutually exclusive.
Sequencing. Dependency check (including Phiki) → spike on a throwaway branch → parity harness → performance gate → feature-flagged rollout → remove API credentials and egress rules → decommission API config. Two amendments from this release: (a) treat the 1.0.0 upgrade and the Phiki 2 upgrade as one atomic unit — do not attempt to land them across separate PRs; (b) do not sequence credential removal before the flag has been dark-launched in production for at least one full release, now with the caveat that a Phiki patch release can change rendering under us, so keep the baseline corpus render as a CI check rather than a one-time exercise.
Maintenance. MIT license is permissive and fork-friendly, and 1.0.0's semver intent reduces the frequency of forced work. But the maintenance surface has widened, not narrowed: we now track two upstreams (torchlight/engine and phiki/phiki) plus their grammar/theme data. The vague changelog means each upgrade requires reading the readme and, realistically, diffing rendered output rather than reading release notes. Budget for that. The fork contingency should be documented at the Phiki layer as well as the engine layer — if grammar fidelity is the problem, forking the engine does not help.
Support. No evident commercial SLA unless tied to a Torchlight subscription. Primary channel remains GitHub issues and maintainer responsiveness — now across two repositories. For a package on the critical path of documentation rendering, that is acceptable only if we accept that we may need to patch locally. 1.0.0 slightly improves our confidence that the maintainers intend to support the public API; it says nothing about response times or SLA.
Scaling. Unchanged in substance and still the most important operational shift: rendering CPU moves from Torchlight's infrastructure onto our app servers. If rendering is request-time, pages with many code blocks will show measurable p95 regression, and PHP-FPM worker saturation becomes a new failure mode under traffic spikes. Phiki 2 is a plausible performance change in either direction — re-baseline rather than assume the old numbers carry over. Mitigations: cache rendered HTML keyed by content hash, pre-render at build time where content is static (docs, blog), and set a hard cap on block size. If the engine supports build-time rendering, prefer that path for anything not user-generated.
Failure modes to instrument for.
engine version change. This is the new top-of-list risk and the reason the parity harness must be a standing CI check keyed by content hash.engine 1.0.0 has dropped Phiki 1 support and we later need to roll back one but not the other.composer update that blocks unrelated work.Ramp-up. Low. Any Laravel developer can install and configure this in an afternoon; the only genuinely new surface is the annotation syntax and the grammar/theme configuration model — and the grammar/theme model is now Phiki's, which is well-documented territory (Shiki-compatible TextMate themes). The real ramp-up cost remains the parity harness and the performance baseline, a few days of TPM-visible effort that should be scheduled explicitly rather than assumed.
Recommendation. Proceed to a time-boxed spike — the same recommendation as before, but with materially better inputs. The blocking architectural unknown (Node/WASM runtime) is now resolved in our favor, and 1.0.0 retires the pre-1.0 churn risk. What replaces those risks is dependency depth: Phiki is a second upstream on the critical path, and 1.0.0 is effectively a breaking-change release because it lands a Phiki major bump alongside it. Gate the decision on (1) lockfile resolution including Phiki, (2) token-level parity against the baseline corpus, and (3) the p95 benchmark on Phiki 2. If all three pass, adopt — with the vendored/fork contingency documented at both the engine and Phiki layers from day one, and the parity harness retained permanently as a CI gate rather than a one-off migration artifact.
How can I help you explore Laravel packages today?