torchlight/torchlight-laravel
Torchlight syntax highlighting for Laravel Blade/Markdown using the Torchlight API. VS Code-compatible highlighting with themes, line highlighting and diffing, no JavaScript required. Includes caching, config publishing, and optional Blade components.
Pros:
Block objects, and custom cache drivers, enabling granular control for complex use cases (e.g., dynamic theming, A/B testing).post-processors and Block::macro() allow integration with Laravel’s ecosystem (e.g., Spatie’s Media Library for code snippets, Livewire for interactive docs).Cons:
file, redis, database) or custom implementations.Torchlight::shouldReceive()) simplifies unit testing.| Risk Area | Severity | Mitigation |
|---|---|---|
| API Downtime | High | Implement local fallback (e.g., static HTML cache or Prism.js as backup). |
| Rate Limiting | Medium | Monitor API usage; implement request throttling or local caching. |
| Cache Invalidation | Medium | Use short TTLs for dynamic content; add manual invalidation endpoints. |
| Theme/Configuration Drift | Low | Version-control torchlight.php; use environment variables for dynamic themes. |
| Livewire/Inertia Conflicts | Low | Test with target versions; check for middleware conflicts. |
| PHP 8.2+ Compatibility | Low | Package supports PHP 8.1+; verify with phpunit/phpunit@^10. |
TORCHLIGHT_CACHE_DRIVER=redis for shared caching.| Stack Component | Compatibility | Notes |
|---|---|---|
| Laravel Core | ✅ 8.0–13.x (tested) | Uses Laravel’s service container, Blade, and caching. |
| PHP | ✅ 8.1+ (recommended) | PHP 8.0 may work but lacks optimizations for PHP 8.1+. |
| Livewire | ✅ 2.x–3.x | Built-in middleware; test with target Livewire version. |
| Inertia.js | ✅ Supported | Middleware handles Inertia responses. |
| Blade/Jigsaw | ✅ Native | Blade components work with Jigsaw (static sites). |
| Queue Workers | ⚠️ Partial | API calls block requests; consider queueing non-critical highlights (e.g., background jobs). |
| Octane | ✅ Supported (v0.5.12+) | Memory leak fixes included. |
| Frontend Frameworks | ❌ Manual | Requires proxying through Laravel or direct API calls. |
| Markdown Processors | ⚠️ Manual | Integrate via PHP-Markdown extensions or custom parsers. |
| API Responses | ⚠️ Manual | Not designed for non-Blade contexts; use Torchlight::highlight() directly. |
composer require torchlight/torchlight-laravel
php artisan torchlight:install
torchlight.php with:
cache: redis (for shared caching) or file (for simplicity).theme: Test dark/light modes (e.g., material-theme-palenight).blade_components: true (default).<x-torchlight code="$codeSnippet" lang="php"/>
try {
return Torchlight::highlight($code);
} catch (\Exception $e) {
return view('fallback.code', ['code' => $code]);
}
torchlight::code).torchlight:install).<pre><code> blocks with Blade components.TORCHLIGHT_CACHE_TTL).How can I help you explore Laravel packages today?