- How do I add Torchlight syntax highlighting to my Laravel app without JavaScript?
- Install the package via `composer require torchlight/torchlight-laravel`, run `php artisan torchlight:install` to publish the config, and use Blade directives like `@torchlight('php', 'code_here')` or the `Torchlight` facade. The package handles server-side rendering automatically.
- Which Laravel versions and PHP versions does Torchlight Laravel support?
- Torchlight Laravel supports Laravel 9–13 and PHP 8.1+. It’s fully compatible with Livewire (v1–v3), Octane, and Jigsaw. Check the [README](https://github.com/torchlight-api/torchlight-laravel) for updates on newer versions.
- Can I use Torchlight for real-time code blocks in Livewire or Octane?
- Yes, Torchlight integrates with Livewire (v1–v3) and Octane. The package auto-registers middleware for Livewire, and Octane users should verify the memory leak fix in v0.5.12. For dynamic updates, ensure your caching strategy aligns with real-time needs.
- How do I configure caching for Torchlight in Laravel?
- Set the `cache` driver in `config/torchlight.php` (e.g., `redis`, `file`, or `database`). Use `env('TORCHLIGHT_CACHE_DRIVER')` to pull from `.env`. Configure TTL (time-to-live) in the cache driver settings for optimal performance, especially for high-traffic sites.
- What happens if the Torchlight API is down or rate-limited?
- Torchlight Laravel includes fallback responses configurable in `torchlight.php`. You can also pre-render snippets during off-peak hours or store critical code blocks locally. For offline mode, disable the API temporarily and rely on cached responses.
- How do I switch between dark/light themes or use custom themes?
- Set the `theme` key in `config/torchlight.php` to any VS Code-compatible theme (e.g., `'material-theme-palenight'`). For multi-theme support, use environment variables or dynamic config loading. Explore all themes at [torchlight.dev/themes](https://torchlight.dev/themes).
- Can I add line numbers or custom CSS to highlighted code blocks?
- Yes, use post-processors via Torchlight’s macro system. For example, extend the `Torchlight` facade to inject line numbers or custom classes. Check the [Torchlight API docs](https://torchlight.dev) for advanced customization options.
- Is Torchlight Laravel secure? How should I store the API token?
- Store your `TORCHLIGHT_TOKEN` in `.env` (never hardcode it). The package uses Laravel’s environment system for secure access. For production, ensure your token has restricted permissions if using paid plans.
- How do I test Torchlight in my Laravel app before deploying?
- Test edge cases like empty code blocks, special characters, and large files (API limits apply). Disable the API temporarily to verify fallback responses. Clear caches with `php artisan cache:clear` and test Blade directives, Livewire interactions, and Octane compatibility.
- Are there alternatives to Torchlight Laravel for syntax highlighting?
- Alternatives include client-side libraries like Prism.js or Highlight.js (requires JS), or self-hosted solutions like Rouge (Ruby) or Pygments (Python). Torchlight stands out for its VS Code compatibility, no-JS requirement, and seamless Laravel integration, but compare API costs and offline capabilities for your use case.