- How do I install Ray in a Laravel project and start debugging immediately?
- Run `composer require spatie/ray` to install the package, then add `Ray::init()` to your `AppServiceProvider`’s `boot()` method. Replace `dd()` or `dump()` calls with `Ray::dd($var)` or `Ray::dump($var)`—no additional configuration is needed for basic usage. The Ray desktop app will automatically receive debug output.
- Does Ray work with Laravel’s Eloquent queries, and how do I log them?
- Yes, Ray has built-in support for Eloquent. Use `Ray::log($query)` or wrap queries in `Ray::debug()` to log raw SQL, bindings, and execution time. For model inspection, pass Eloquent models directly to `Ray::dd($model)` to see relationships, attributes, and even query builder output.
- Can I use Ray in production, or is it only for development?
- Ray is primarily designed for development, but you can use it cautiously in staging with the **Ray Gateway** for remote debugging. Avoid production use unless you’ve configured strict filtering (e.g., `Ray::ignore()` for sensitive routes) and sampled logging. The free tier limits messages to 20/session, so production use requires a paid license.
- How does Ray compare to Laravel Telescope for debugging?
- Ray offers real-time, interactive debugging like browser DevTools, while Telescope is a web-based log viewer. Ray excels at **instant inspection** of variables, queries, and performance metrics, whereas Telescope is better for **historical analysis** of requests, jobs, and exceptions. Use Ray for active debugging and Telescope for post-mortem analysis.
- Will Ray slow down my Laravel application, especially in high-traffic environments?
- Ray introduces minimal overhead, but network-bound operations (e.g., sending debug data to the local Ray server) can impact performance in high-load scenarios. Mitigate this by using `Ray::ignore()` for non-critical paths, excluding queues/cron jobs, or disabling Ray in production. Benchmark with tools like Laravel Debugbar to measure impact.
- How do I sanitize sensitive data (e.g., passwords, API keys) before sending to Ray?
- Use `Ray::ignore()` to exclude sensitive variables or data from logging. For example, `Ray::ignore('password')` will redact any array/property named `password`. For request payloads, use middleware like `Ray::ignoreRequestPayload()` or manually filter data with `Ray::sanitize()`. Always validate against GDPR/PCI compliance requirements.
- Can I integrate Ray with Laravel’s testing (Pest or PHPUnit) to debug failed tests?
- Yes, Ray works seamlessly with Pest and PHPUnit. Add `Ray::init()` to your test setup, and use `Ray::dd()` or `Ray::dump()` in test failures to inspect variables. For Pest, enable it globally in `pest.php` with `uses(RayServiceProvider::class)`. This replaces `dump()` in tests and provides a richer debugging experience.
- Does Ray support Livewire or Inertia.js debugging, including component state and props?
- Ray has **experimental support** for Livewire and Inertia via custom payloads. Use `Ray::log($livewireComponent)` to inspect props, state, and emitted events. For Inertia, log the page component and its props with `Ray::dd(inertia()->current())`. Check the [Ray docs](https://myray.app/docs/php) for updates on framework-specific integrations.
- How can I migrate from `dd()`, `dump()`, and `Log::debug()` to Ray without breaking existing code?
- Use **Rector** to automate replacements (e.g., `dd()` → `Ray::dd()`). For manual migration, start with critical paths (e.g., API endpoints, Eloquent queries) and gradually replace calls. Wrap legacy logs in `Ray::log()` for consistency. Test thoroughly, as Ray’s output format differs from `dump()` (e.g., collapsible arrays, interactive inspection).
- What are the licensing costs for Ray, and how do they scale with team size?
- Ray offers a **free tier** (20 messages/session) and paid licenses starting at ~$50/year per developer. Team licenses scale with usage (e.g., unlimited messages, shared sessions). For Laravel agencies, contact Spatie for enterprise pricing. The desktop app (MyRay.app) requires a license, but the PHP package (`spatie/ray`) is MIT-licensed and free to use.