{"id":19325085,"url":"https://github.com/spatie/x-ray","last_synced_at":"2025-05-16T18:06:37.741Z","repository":{"id":42084694,"uuid":"399057732","full_name":"spatie/x-ray","owner":"spatie","description":"Scan source code for calls to ray() and related calls.","archived":false,"fork":false,"pushed_at":"2025-02-03T14:46:34.000Z","size":545,"stargazers_count":76,"open_issues_count":0,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-16T18:06:11.683Z","etag":null,"topics":["code-analysis","code-search","ray"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spatie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"spatie","custom":"https://spatie.be/open-source/support-us"}},"created_at":"2021-08-23T10:14:53.000Z","updated_at":"2025-04-04T04:41:11.000Z","dependencies_parsed_at":"2024-02-02T08:42:07.462Z","dependency_job_id":"2da8deee-587f-4ff7-9b44-25b949bb4083","html_url":"https://github.com/spatie/x-ray","commit_stats":{"total_commits":301,"total_committers":10,"mean_commits":30.1,"dds":0.2491694352159468,"last_synced_commit":"bd4c8776a5df84311c063b43e1355486fe3849fa"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fx-ray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fx-ray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fx-ray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spatie%2Fx-ray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spatie","download_url":"https://codeload.github.com/spatie/x-ray/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582905,"owners_count":22095518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-analysis","code-search","ray"],"created_at":"2024-11-10T02:08:50.457Z","updated_at":"2025-05-16T18:06:37.719Z","avatar_url":"https://github.com/spatie.png","language":"PHP","funding_links":["https://github.com/sponsors/spatie","https://spatie.be/open-source/support-us"],"categories":[],"sub_categories":[],"readme":"# Quickly scan source code for calls to Ray\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://static.permafrost.dev/images/x-ray/x-ray-logo.png\" alt=\"x-ray logo\" height=\"200\" style=\"display:block\"\u003e\n    \u003cbr\u003e\u003cbr\u003e\n    \u003c!--img src=\"https://img.shields.io/packagist/v/spatie/x-ray.svg\" alt=\"Packagist Version\"--\u003e  \n    \u003cimg src=\"https://img.shields.io/github/v/release/spatie/x-ray.svg?sort=semver\u0026logo=github\" alt=\"Package Version\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/license/spatie/x-ray.svg?logo=opensourceinitiative\" alt=\"license\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/spatie/x-ray/run-tests.yml?style=flat-square\" alt=\"Test Run Status\"\u003e\n    \u003cimg src=\"https://img.shields.io/packagist/dt/spatie/x-ray.svg?style=flat-square\" alt=\"Downloads\" /\u003e\n\u003c/p\u003e\n\nThis package can quickly scan source code for calls to `ray()`, `rd()`, `Ray::*`, and `-\u003eray()` helper methods from the [spatie/ray](https://github.com/spatie/ray) and [spatie/laravel-ray](https://github.com/spatie/laravel-ray) packages.\n\nThe 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.\n\nThe 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.\n\nVisit [myray.app](https://myray.app) for information on downloading the Ray debugging app.\n\n## Installation\n\n```bash\ncomposer require spatie/x-ray --dev\n```\n\n## Usage\n\nSpecify one or more valid path names and/or filenames to scan:\n\n```bash\n./vendor/bin/x-ray ./app/Actions/MyAction.php ./app/Models/*.php ./tests --snippets\n```\n\nDisplay a summary table of the located calls within `./src` and `./tests` while also ignoring some files:\n\n```bash\n./vendor/bin/x-ray \\\n  --summary \\\n  --ignore src/MyClass.php \\\n  --ignore 'test/fixtures/*.php' \\\n  ./src ./tests\n```\n\nDisplay each filename \u0026 pass/fail status, along with compact results:\n\n```bash\n./vendor/bin/x-ray ./app --compact --verbose\n```\n\n## Available Options\n\n| Flag | Description\n|---|---|\n|`--compact` or `-c` | Minimal output.  Display each result on a single line. |\n|`--github` or `-g` | GitHub Annotation output.  Use `error` command to create annotation. Useful when you are running x-ray within GitHub Actions. |\n|`--ignore` or `-i` | Ignore a file or path, can be specified multiple times. Accepts glob patterns. |\n|`--no-progress` or `-P` | Don't display the progress bar while scanning files |\n|`--snippets` or `-S` | Display code snippets from located calls |\n|`--summary` or `-s` | Display a summary of the files/calls discovered |\n|`--verbose` or `-v` | Display each filename and pass/fail status while scanning. Implies `--no-progress`. |\n\n## Configuration files\n\nCreate a file named `x-ray.yml` or `x-ray.yml.dist` in the root directory of your project to configure the package.\n\nIf the configuration file exists, it must have the root sections `functions` and `paths`.\n\nEach 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)_.  \n\nBy default, `functions.include` matches the `ray` and `rd` functions.\n\n```yaml\nfunctions:\n  include:\n    - '*'\n\npaths:\n  include:\n    - 'tests/fixtures/*'\n  ignore:\n    - tests\n    - 'SettingsTest.php'\n```\n\n## Automation\n\n`x-ray` was designed to be used not only as a manual utility, but in conjunction with automation tools.  \n\n## Github workflows\n\nYou may use `x-ray` within a github workflow to help ensure you don't commit any calls to `ray()`.\n\nThe following example workflow runs unit tests with PHPUnit and then runs `x-ray`:\n\n```yaml\nname: run-tests\n\non: \n  push:\n    branches:\n      - main\n  pull_request:\n\njobs:\n  test:\n    runs-on: ${{ matrix.os }}\n    strategy:\n      fail-fast: true\n      matrix:\n        os: [ubuntu-latest]\n        php: [8.3, 8.2, 8.1]\n\n    name: P${{ matrix.php }} - ${{ matrix.os }}\n\n    steps:\n      - name: Checkout code\n        uses: actions/checkout@v4\n\n      - name: Setup PHP\n        uses: shivammathur/setup-php@v2\n        with:\n          php-version: ${{ matrix.php }}\n          extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo\n          coverage: pcov\n\n      - name: Setup problem matchers\n        run: |\n          echo \"::add-matcher::${{ runner.tool_cache }}/php.json\"\n          echo \"::add-matcher::${{ runner.tool_cache }}/phpunit.json\"\n\n      - name: Install dependencies\n        run: composer update --prefer-stable --prefer-dist --no-interaction\n\n      - name: Execute tests\n        run: ./vendor/bin/phpunit\n        \n      - name: Check for ray calls\n        run: ./vendor/bin/x-ray . --compact\n```\n\n## Git hooks\n\nIn some cases you may want to use a git `pre-commit` hook to avoid commiting any `ray()` calls:\n\n```bash\n#!/bin/sh\n\necho \"Checking for ray() calls...\\n\"\n\nx-ray -s .\nrayScanExitCode=$?\n\nprintf '%*s\\n' \"${COLUMNS:-$(tput cols)}\" '' | tr ' ' -\n\nlocalPreCommitExitCode=0\nif [ -e ./.git/hooks/pre-commit ]; then\n    ./.git/hooks/pre-commit \"$@\"\n    localPreCommitExitCode=$?\nfi\n\nexit $rayScanExitCode || $localPreCommitExitCode\n```\n\nYou can also use `x-ray` with husky in your `package.json` configuration:\n\n```json\n...\n\"husky\": {\n    \"hooks\": {\n        \"pre-commit\": \"lint-staged \u0026\u0026 .x-ray -s .\"\n    }\n},\n....\n```\n\n\n## Screenshots\n\nVarious screenshots can be viewed in [the docs](docs/screenshots.md).\n\n## Testing\n\n```bash\n./vendor/bin/phpunit\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\n## Contributing\n\nPlease see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details.\n\n## Security Vulnerabilities\n\nPlease review [our security policy](../../security/policy) on how to report security vulnerabilities.\n\n## Credits\n\n- [Patrick Organ](https://github.com/patinthehat)\n- [Alex Vanderbist](https://github.com/AlexVanderbist)\n- [Tom Witkowski](https://github.com/Gummibeer)\n- [All Contributors](../../contributors)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fx-ray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspatie%2Fx-ray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspatie%2Fx-ray/lists"}