- How do I install spatie/x-ray for Laravel projects?
- Run `composer require spatie/x-ray --dev` in your project directory. The package is designed as a development dependency to avoid bloating production builds. It integrates seamlessly with Laravel’s Composer ecosystem.
- Does spatie/x-ray work with Laravel’s service container or Facade calls to Ray?
- Yes, it detects all Ray-related calls, including Facade methods like `Ray::debug()`, `->ray()`, and even dynamic calls via the service container. It uses static analysis to identify usage patterns across your entire codebase.
- Can I use spatie/x-ray in GitHub Actions to block deployments with leftover Ray calls?
- Absolutely. Use the `--github` flag to generate GitHub Actions annotations, and set the workflow to fail if the exit code is non-zero. Example: `run: ./vendor/bin/x-ray scan --github && exit $?`.
- What Laravel versions does spatie/x-ray support?
- The package works with any Laravel version that uses Ray (v1.0+). It’s not Laravel-specific but focuses on Ray debugging calls, so it’s compatible with Laravel 8.x, 9.x, and 10.x. Test thoroughly if using older Laravel 7.x.
- How do I ignore specific files or directories from the scan?
- Use the `--ignore` flag repeatedly. For example, `./vendor/bin/x-ray --ignore tests/Unit --ignore config/ ./app` skips those paths. You can also ignore glob patterns like `--ignore 'app/Console/*.php'`.
- Will spatie/x-ray generate false positives for non-Ray calls (e.g., custom methods named `ray`)?
- It’s possible, especially in dynamic code or reflection-heavy projects. To mitigate this, use the `--snippets` flag to review context or whitelist paths/files with `--ignore`. Custom PHPStan rules can further refine accuracy.
- Can I integrate spatie/x-ray into my CI pipeline to enforce Ray cleanup?
- Yes. Add it to your CI (e.g., GitHub Actions, GitLab CI) with a step like `run: ./vendor/bin/x-ray scan && exit $?`. The non-zero exit code on Ray detections makes it ideal for blocking merges or deployments.
- Does spatie/x-ray modify files or only report findings?
- It **only reports** findings—no files are altered. The tool outputs locations of Ray calls (e.g., line numbers, snippets) so you can manually remove them before deployment. This ensures safety in CI/CD pipelines.
- Are there alternatives to spatie/x-ray for scanning Ray calls?
- Manual searches with `grep` or `ripgrep` (`rg 'ray('`) are alternatives, but they lack CI integration and structured output. For deeper analysis, consider PHPStan with custom rules, though spatie/x-ray is optimized for Ray-specific scans.
- How do I customize spatie/x-ray to handle project-specific Ray usage (e.g., allow in tests)?
- Use the `--ignore` flag for directories like `--ignore tests/` or extend PHPStan rules for granular control. For advanced cases, fork the package or create a custom PhpParser-based scanner to override default behavior.