- How do I install spatie/ray in a Laravel project?
- Run `composer require spatie/ray --dev` to install the package. For Laravel-specific features, use `composer require spatie/laravel-ray --dev` instead. The package auto-registers in Laravel, so no additional setup is needed beyond configuring `config/ray.php` if required.
- Does spatie/ray work with Laravel 13?
- Yes, spatie/ray officially supports Laravel 10–13. For Laravel 13, use the latest `spatie/laravel-ray` package, which includes Laravel-specific helpers like the `ray()` facade. Check the [Laravel-Ray documentation](https://myray.app/docs/laravel) for version-specific details.
- Can I use Ray to debug Eloquent queries?
- Absolutely. Enable query logging with `DB::enableQueryLog()`, then use `ray()` to inspect queries alongside their results. Ray displays query plans, bindings, and execution time—ideal for optimizing slow queries in Laravel.
- How does Ray handle sensitive data in production?
- Ray automatically filters sensitive data (e.g., passwords, tokens) when `RAY_ENV=production`. For extra safety, use `ray()->withoutSensitiveData()` to exclude specific variables. The package is MIT-licensed and designed for secure debugging.
- Will Ray slow down my Laravel application in production?
- No, Ray has minimal overhead in production. Disable debugging entirely with `RAY_ENV=production`, or use `RAY_COMPRESS=1` to reduce payload size. Avoid frequent `ray()` calls in hot paths, as they stream data to the desktop app.
- Can I debug Livewire or Inertia.js components with Ray?
- Yes, Ray integrates with Livewire and Inertia via its MCP server. Use `window.Ray` in JavaScript to sync PHP and frontend debugging. Inspect component props, state, and Blade templates in real time—no terminal juggling required.
- What’s the difference between spatie/ray and spatie/laravel-ray?
- spatie/ray is the core package for vanilla PHP, while `spatie/laravel-ray` adds Laravel-specific features like the `ray()` facade, Eloquent query inspection, and middleware. Use the latter for full Laravel integration.
- How do I measure code performance with Ray?
- Use `ray()->timeSection('section_name', fn() => $yourCode)` to measure execution time. Ray displays timings in a collapsible UI, helping you identify bottlenecks in Laravel controllers, jobs, or commands.
- Does Ray work in CI/CD environments?
- Ray is primarily a desktop tool, but you can log output to a file or use CLI fallbacks. For CI, consider `RAY_ENV=production` to disable debugging or use `spatie/laravel-log` as an alternative for structured logs.
- Are there alternatives to Ray for Laravel debugging?
- Yes, alternatives include Laravel Debugbar (browser-based), Telescope (database-driven), and Xdebug (CLI/IDE). Ray stands out for its real-time desktop UI, cross-language sync (PHP/JS), and seamless Laravel integration with minimal setup.