- How do I install spatie/yii-ray in my Yii2 project?
- Run `composer require spatie/yii-ray` in your Yii2 project directory. Then, initialize Ray in your `config/web.php` by adding the YiiRay component to the `components` array. Follow the [official Yii2 Ray docs](https://myray.app/docs/php/yii/getting-started) for step-by-step setup.
- Does spatie/yii-ray work with Yii2’s built-in debug tools like Yii::debug()?
- Yes, it integrates seamlessly with Yii2’s native debugging methods. You can replace `Yii::debug()` calls with `Ray::debug()` or `Ray::info()`, and all output will appear in the Ray desktop app. The package also intercepts Yii2’s log messages for centralized debugging.
- What Yii2 versions does spatie/yii-ray support?
- The package is designed for Yii2 (not Yii3 or Laravel). It supports Yii2’s LTS versions (e.g., 2.0.x) and later. Always check the [package’s changelog](https://github.com/spatie/yii-ray/blob/main/CHANGELOG.md) for version-specific notes before upgrading.
- Can I use Ray’s pause execution feature in Yii2?
- Yes, Ray’s pause execution feature works in Yii2. You can halt script execution mid-flow to inspect variables or debug complex logic, just like in Laravel or vanilla PHP. This is especially useful for debugging Yii2’s event-driven architecture (e.g., `on beforeAction`).
- How does Ray handle sensitive data like API keys or PII in debug messages?
- Ray does not automatically sanitize sensitive data. You must manually filter or redact sensitive information before sending it to Ray using PHP’s `var_export()` or custom logic. For production, consider disabling Ray entirely or using environment-based conditional logging (e.g., `YII_DEBUG` mode).
- What’s the performance impact of using Ray in a high-traffic Yii2 app?
- Ray introduces minimal overhead, primarily from serializing debug data. For production-like loads, test with tools like Blackfire or Xdebug to measure latency. Disable Ray in non-debug environments (e.g., via `YII_DEBUG = false`) to avoid any impact on performance.
- Can I use Ray alongside Yii Debug Toolbar or Xdebug?
- Yes, Ray can coexist with Yii Debug Toolbar or Xdebug. However, avoid sending duplicate debug data to both tools to prevent clutter. Ray’s strength lies in its desktop UI for complex data (e.g., arrays, queries), while Toolbar/Xdebug may suit simpler frontend debugging.
- Do I need to self-host Ray’s MCP server, or can I use the cloud version?
- You can use either. The free tier includes a cloud MCP server, but for local development or staging, self-hosting (via Docker or native install) is recommended to avoid latency. The cloud version is ideal for remote teams but may have rate limits or SLAs to consider.
- How do I transition from Yii::debug() to Ray in my Yii2 app?
- Start by replacing critical `Yii::debug()` calls with `Ray::debug()` in key components (e.g., controllers, models). Use Ray’s [performance tools](https://myray.app/docs/php/performance) to measure execution time for complex queries or API responses. Pilot in staging first to test the workflow.
- What are the licensing costs for using Ray in production?
- Ray offers a free tier with up to 20 messages per session, suitable for development. For production use, a paid license unlocks unlimited messages, advanced features, and cloud MCP hosting. Check [Spatie’s pricing page](https://spatie.be/products/ray) for details and team discounts.