- How do I install and set up spatie/laravel-ray in a Laravel project?
- Run `composer require spatie/laravel-ray` and execute `php artisan ray:install`. The package auto-detects your Laravel version and sets up minimal configuration. No additional steps are needed unless you want to customize watchers or ignore specific data.
- Does spatie/laravel-ray work with Laravel 13, or is it limited to older versions?
- Yes, it officially supports Laravel 11–13 (as of v1.43.x) with backported fixes for PHP 8.1–8.5. The package is version-agnostic and adapts to your Laravel installation without breaking changes in recent releases.
- Can I use Ray for debugging in production, or is it only for development?
- Ray is designed for development only. When `APP_DEBUG=false`, Ray is automatically disabled. For production, use conditional checks like `if (app()->environment('local')) ray($var)` or environment-specific configurations to prevent accidental data leaks.
- How does Ray handle sensitive data like passwords or API keys in debug output?
- Ray provides sanitization options via `Ray::ignore([Password::class])` or environment variables like `RAY_ENABLED=false` in staging/prod. Always avoid sending sensitive data to Ray, even in development, by filtering it before calls.
- Will Ray slow down my Laravel application in development?
- Ray has minimal overhead, but heavy usage (e.g., `ray()` in loops) can impact performance. Mitigate this by rate-limiting messages via `.env` (e.g., `RAY_MAX_MESSAGES_PER_MINUTE=100`) or using it selectively for critical debugging.
- How does Ray compare to Laravel Telescope or Sentry for debugging?
- Ray focuses on real-time, interactive debugging with a desktop app, while Telescope is a web-based log viewer and Sentry is for error tracking. Ray augments these tools by providing instant variable inspection, performance metrics, and execution pauses—ideal for deep-dive debugging.
- Can I use Ray in headless or cloud-based Laravel deployments without a desktop app?
- Ray requires a local desktop app by default, but you can use `ray:offline` mode for air-gapped environments or self-host the MCP server (Ray’s backend). For cloud deployments, consider SSH tunneling to access the Ray app remotely.
- How do I debug SQL queries, HTTP requests, or Blade templates with Ray?
- Ray includes built-in watchers for queries (`QueryWatcher`), HTTP requests (`RequestWatcher`), and Blade templates (`BladeWatcher`). Enable them via configuration or use `ray()` directly in your code. For example, `ray(new User)` will display the full object structure.
- Are there alternatives to spatie/laravel-ray for Laravel debugging?
- Alternatives include Laravel Telescope (for logs/queries), Sentry (for errors), and Xdebug (for step debugging). Ray stands out for its cross-language support (PHP, JS), rich UI, and seamless Laravel integration without requiring CLI or web interfaces.
- How can I test my Laravel application with Ray enabled without affecting production?
- Ray is non-intrusive and can be mocked in tests using `Ray::shouldReceive('send')->never()`. Disable Ray in non-local environments via `.env` (e.g., `RAY_ENABLED=false`) and use conditional logic to ensure debug calls don’t interfere with test assertions or CI pipelines.