Configure X-Ray To Detect Ray Calls

Ray provides a first-party package named x-ray, allowing you detect remaining Ray calls in your application.

The primary use case is when calls to Ray cannot be left in source code before deploying, even if Ray is disabled. This package does NOT remove the calls, it simply displays their locations so they can be removed manually.

The exit code of the x-ray command is zero if no Ray calls are found, and non-zero if calls are found. This allows the package to be used in an automated environment such as Github Workflows.


composer require spatie/x-ray --dev


Specify one or more valid path names and/or filenames to scan:

./vendor/bin/x-ray ./app/Actions/MyAction.php ./app/Models/*.php ./tests --snippets

Display a summary table of the located calls within ./src and ./tests while also ignoring some files:

./vendor/bin/x-ray \
  --summary \
  --ignore src/MyClass.php \
  --ignore 'test/fixtures/*.php' \
  ./src ./tests

Display each filename & pass/fail status, along with compact results:

./vendor/bin/x-ray ./app --compact --verbose

#Available options

Flag Description
--compact or -c Minimal output. Display each result on a single line.
--github or -g GitHub Annotation output. Use error command to create annotation. Useful when you are running x-ray within GitHub Actions.
--ignore or -i Ignore a file or path, can be specified multiple times. Accepts glob patterns.
--no-progress or -P Don't display the progress bar while scanning files
--snippets or -S Display code snippets from located calls
--summary or -s Display a summary of the files/calls discovered
--verbose or -v Display each filename and pass/fail status while scanning. Implies --no-progress.

See the complete documentation with examples, including Github Workflow Action examples, at spatie/x-ray.

Help us improve this page