- How do I install Torchlight Laravel and get started?
- Run `composer require torchlight/torchlight-laravel` and then `php artisan torchlight:install` to publish the config file. Add your Torchlight API token to `.env` under `TORCHLIGHT_TOKEN` and configure caching, theme, and host in `config/torchlight.php`.
- Which Laravel versions does this package support?
- Torchlight Laravel supports Laravel 9 through 13 and requires PHP 8.1+. Always check the package’s changelog for version-specific updates, especially if using Livewire or Octane.
- Can I use Torchlight Laravel with Livewire?
- Yes, it has built-in support for Livewire 2 and 3. Livewire 1 support was dropped in v0.5.13, so ensure compatibility if using older versions. Real-time updates work seamlessly with Livewire’s reactivity.
- What happens if the Torchlight API is down or rate-limited?
- The package includes configurable fallback responses (e.g., plain HTML or cached content) via `fallback_response` in the config. You can also customize this behavior using post-processing hooks for graceful degradation.
- How does caching work, and can I invalidate it for dynamic content?
- Caching is configurable via `TORCHLIGHT_CACHE_DRIVER` (supports Redis, file, etc.). For dynamic content like user-uploaded code, manually clear the cache using `Torchlight::clearCache()` or implement a custom cache key strategy.
- Are there any premium themes or custom styling options?
- Torchlight supports all VS Code-compatible themes (free and premium) via the `theme` config key. Custom styling can be achieved using post-processing hooks or by overriding the Blade component’s output with CSS.
- Does Torchlight Laravel work with Jigsaw static sites?
- Yes, it’s fully compatible with Jigsaw. The package ensures non-destructive block clearing during view compilation (fixed in v0.3.0), so syntax highlighting works seamlessly in static Laravel sites.
- Can I inject analytics or tracking pixels into highlighted code blocks?
- Yes, use the `postProcess` macro on the `Block` class to inject custom HTML (e.g., tracking pixels) after rendering. This allows for analytics without breaking the highlighting logic.
- What are the API costs for production use beyond the free tier?
- Torchlight’s free tier covers personal and open-source projects. For enterprise or high-traffic production use, check their [pricing page](https://torchlight.dev/pricing) for paid plans. The package’s caching mitigates costs by reducing API calls.
- Are there alternatives if I need offline or client-side caching?
- Torchlight Laravel is server-side only. For offline support, consider client-side libraries like Prism.js or Highlight.js, though they require JavaScript. The package’s caching reduces API latency but doesn’t replace client-side caching.