- How do I install spatie/global-ray for Laravel and use ray() globally?
- Run `composer global require spatie/global-ray` and execute `global-ray install`. This modifies your `php.ini` to load Ray’s helper functions globally, so you can call `ray()` in any PHP file—Laravel or otherwise—without requiring the package in each project.
- Will this work with Laravel’s built-in dump() and dd() functions?
- Yes, but for custom output (e.g., HTML, queries, or formatted arrays), use `ray()` explicitly. Laravel’s `dump()`/`dd()` rely on the Symfony VarDumper, while `ray()` sends data to the Ray desktop app with richer formatting and interactivity.
- Does spatie/global-ray support PHP 8.0 or older versions?
- The package is officially tested on PHP 8.1+. While it may work on older versions, Spatie recommends PHP 8.1+ for stability, especially if using Ray’s advanced features like performance profiling or AI interaction via MCP.
- How do I prevent Ray from exposing sensitive data in production?
- Disable Ray in production by setting `RAY_ENABLED=false` in your `.env` file. For local development, use Ray’s built-in redaction rules to mask secrets (e.g., passwords, API keys) by configuring them in the Ray desktop app’s settings.
- Can I use this package in CI/CD pipelines without cluttering logs?
- Yes, exclude CI environments by setting `RAY_ENABLED=false` in your `.env.ci` file. Alternatively, wrap `ray()` calls in environment checks like `if (!app()->environment('ci')) { ray($data); }` to avoid accidental debug output.
- What’s the difference between this and Laravel Debugbar?
- Laravel Debugbar is framework-specific and integrates with Laravel’s internals (e.g., queries, events). `spatie/global-ray` works across *any* PHP project, including CLI scripts and non-Laravel apps, and offers richer output (HTML, Markdown, performance metrics) via the Ray desktop app.
- How do I measure performance with ray() in Laravel?
- Use `ray()->performance()` to start a timer, then call `ray()->stopPerformance()` to log execution time. For example: `$timer = ray()->performance('query'); DB::query(...); ray()->stopPerformance($timer);`—this sends timing data to Ray’s desktop UI.
- Does this package work with Docker or Kubernetes deployments?
- Yes, but the Ray desktop app must connect to the PHP process via a shared socket (default: `unix:///tmp/ray.sock`). In Docker, ensure the socket path is accessible (e.g., mount `/tmp/ray.sock` as a volume) and configure Ray’s MCP server URL if using AI features.
- Is there a free tier, or do I need to pay for Ray’s full features?
- Ray offers a free trial with limited messages per session. Full features (e.g., performance profiling, AI interaction, and unlimited usage) require a paid license. The `spatie/global-ray` package itself is free and open-source.
- How do I disable ray() globally for specific environments (e.g., staging)?
- Set `RAY_ENABLED=false` in your `.env` file for staging. For granular control, use environment checks: `if (app()->environment('staging')) { return; } ray($data);`. The package respects these settings without requiring manual uninstallation.