PHPackages                             spatie/x-ray - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Search &amp; Filtering](/categories/search)
4. /
5. spatie/x-ray

ActiveLibrary[Search &amp; Filtering](/categories/search)

spatie/x-ray
============

Quickly scan source code for calls to Ray

1.2.2(4mo ago)80411.5k↓67.8%7[1 PRs](https://github.com/spatie/x-ray/pulls)20MITPHPPHP ^8.0CI passing

Since Sep 16Pushed 5d ago3 watchersCompare

[ Source](https://github.com/spatie/x-ray)[ Packagist](https://packagist.org/packages/spatie/x-ray)[ Docs](https://github.com/spatie/x-ray)[ GitHub Sponsors](https://github.com/sponsors/permafrost-dev)[ GitHub Sponsors](https://github.com/sponsors/spatie)[ RSS](/packages/spatie-x-ray/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (7)Dependencies (8)Versions (13)Used By (20)

Quickly scan source code for calls to Ray
=========================================

[](#quickly-scan-source-code-for-calls-to-ray)

 [![x-ray logo](https://camo.githubusercontent.com/425fb6b07e3919ab27ad1bd2ded59c252ec134aaba0b771b5975b8929d689648/68747470733a2f2f7374617469632e7065726d6166726f73742e6465762f696d616765732f782d7261792f782d7261792d6c6f676f2e706e67)](https://camo.githubusercontent.com/425fb6b07e3919ab27ad1bd2ded59c252ec134aaba0b771b5975b8929d689648/68747470733a2f2f7374617469632e7065726d6166726f73742e6465762f696d616765732f782d7261792f782d7261792d6c6f676f2e706e67)

 [![Package Version](https://camo.githubusercontent.com/b248dedc3f60570b5613716570889243fcc5191729baabae84ec8b1ad38dec23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7370617469652f782d7261792e7376673f736f72743d73656d766572266c6f676f3d676974687562)](https://camo.githubusercontent.com/b248dedc3f60570b5613716570889243fcc5191729baabae84ec8b1ad38dec23/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f7370617469652f782d7261792e7376673f736f72743d73656d766572266c6f676f3d676974687562) [![license](https://camo.githubusercontent.com/5dc7dff358a950068f09fdcc2d538ba034b6c5ac3ff8516a00394aec33ef07de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7370617469652f782d7261792e7376673f6c6f676f3d6f70656e736f75726365696e6974696174697665)](https://camo.githubusercontent.com/5dc7dff358a950068f09fdcc2d538ba034b6c5ac3ff8516a00394aec33ef07de/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7370617469652f782d7261792e7376673f6c6f676f3d6f70656e736f75726365696e6974696174697665) [![Test Run Status](https://github.com/spatie/x-ray/actions/workflows/run-tests.yml/badge.svg)](https://github.com/spatie/x-ray/actions/workflows/run-tests.yml/badge.svg) [![Downloads](https://camo.githubusercontent.com/4c9738c59ba1c22a58f716d4eeadf5468888aa721b6cb18888858ae71533e1ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f782d7261792e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/4c9738c59ba1c22a58f716d4eeadf5468888aa721b6cb18888858ae71533e1ff/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f782d7261792e7376673f7374796c653d666c61742d737175617265)

This package can quickly scan source code for calls to `ray()`, `rd()`, `Ray::*`, and `->ray()` helper methods from the [spatie/ray](https://github.com/spatie/ray) and [spatie/laravel-ray](https://github.com/spatie/laravel-ray) packages.

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.

Visit [myray.app](https://myray.app) for information on downloading the Ray debugging app.

Installation
------------

[](#installation)

```
composer require spatie/x-ray --dev
```

Usage
-----

[](#usage)

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 &amp; pass/fail status, along with compact results:

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

Available Options
-----------------

[](#available-options)

FlagDescription`--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`.Configuration files
-------------------

[](#configuration-files)

Create a file named `x-ray.yml` or `x-ray.yml.dist` in the root directory of your project to configure the package.

If the configuration file exists, it must have the root sections `functions` and `paths`.

Each section may have an `ignore` or `include` item, both, or neither. Each item contains an array of strings, and includes override ignores if an entry exists in both. Add a `*` item to ignore or include all matches *(make sure to quote the asterisk)*.

By default, `functions.include` matches the `ray` and `rd` functions.

```
functions:
  include:
    - '*'

paths:
  include:
    - 'tests/fixtures/*'
  ignore:
    - tests
    - 'SettingsTest.php'
```

Automation
----------

[](#automation)

`x-ray` was designed to be used not only as a manual utility, but in conjunction with automation tools.

Github workflows
----------------

[](#github-workflows)

You may use `x-ray` within a github workflow to help ensure you don't commit any calls to `ray()`.

The following example workflow runs unit tests with PHPUnit and then runs `x-ray`:

```
name: run-tests

on:
  push:
    branches:
      - main
  pull_request:

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest]
        php: [8.3, 8.2, 8.1]

    name: P${{ matrix.php }} - ${{ matrix.os }}

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
          coverage: pcov

      - name: Setup problem matchers
        run: |
          echo "::add-matcher::${{ runner.tool_cache }}/php.json"
          echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

      - name: Install dependencies
        run: composer update --prefer-stable --prefer-dist --no-interaction

      - name: Execute tests
        run: ./vendor/bin/phpunit

      - name: Check for ray calls
        run: ./vendor/bin/x-ray . --compact
```

Git hooks
---------

[](#git-hooks)

In some cases you may want to use a git `pre-commit` hook to avoid commiting any `ray()` calls:

```
#!/bin/sh

echo "Checking for ray() calls...\n"

x-ray -s .
rayScanExitCode=$?

printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' -

localPreCommitExitCode=0
if [ -e ./.git/hooks/pre-commit ]; then
    ./.git/hooks/pre-commit "$@"
    localPreCommitExitCode=$?
fi

exit $rayScanExitCode || $localPreCommitExitCode
```

You can also use `x-ray` with husky in your `package.json` configuration:

```
...
"husky": {
    "hooks": {
        "pre-commit": "lint-staged && .x-ray -s ."
    }
},
....
```

Screenshots
-----------

[](#screenshots)

Various screenshots can be viewed in [the docs](docs/screenshots.md).

Testing
-------

[](#testing)

```
./vendor/bin/phpunit
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Patrick Organ](https://github.com/patinthehat)
- [Alex Vanderbist](https://github.com/AlexVanderbist)
- [Tom Witkowski](https://github.com/Gummibeer)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

61

—

FairBetter than 98% of packages

Maintenance88

Actively maintained with recent releases

Popularity50

Moderate usage in the ecosystem

Community33

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 82.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~268 days

Recently: every ~349 days

Total

7

Last Release

145d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7535935?v=4)[Spatie](/maintainers/spatie)[@spatie](https://github.com/spatie)

---

Top Contributors

[![patinthehat](https://avatars.githubusercontent.com/u/5508707?v=4)](https://github.com/patinthehat "patinthehat (325 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (24 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (22 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (6 commits)")[![AdrianMrn](https://avatars.githubusercontent.com/u/12762044?v=4)](https://github.com/AdrianMrn "AdrianMrn (5 commits)")[![colinmackinlay](https://avatars.githubusercontent.com/u/7833362?v=4)](https://github.com/colinmackinlay "colinmackinlay (3 commits)")[![thecaliskan](https://avatars.githubusercontent.com/u/13554944?v=4)](https://github.com/thecaliskan "thecaliskan (3 commits)")[![Nielsvanpach](https://avatars.githubusercontent.com/u/10651054?v=4)](https://github.com/Nielsvanpach "Nielsvanpach (2 commits)")[![AlexVanderbist](https://avatars.githubusercontent.com/u/6287961?v=4)](https://github.com/AlexVanderbist "AlexVanderbist (2 commits)")[![binotaliu](https://avatars.githubusercontent.com/u/67255597?v=4)](https://github.com/binotaliu "binotaliu (1 commits)")[![jasonvarga](https://avatars.githubusercontent.com/u/105211?v=4)](https://github.com/jasonvarga "jasonvarga (1 commits)")

---

Tags

code-analysiscode-searchrayspatieraysearchpermafrost

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/spatie-x-ray/health.svg)

```
[![Health](https://phpackages.com/badges/spatie-x-ray/health.svg)](https://phpackages.com/packages/spatie-x-ray)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

103519.9k53](/packages/friendsoftypo3-content-blocks)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M420](/packages/drupal-core-recommended)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M572](/packages/shopware-core)[jolicode/castor

A lightweight and modern task runner. Automate everything. In PHP.

54743.1k4](/packages/jolicode-castor)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
