PHPackages                             jaydeep/laravel-xray - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. jaydeep/laravel-xray

ActiveLibrary[Testing &amp; Quality](/categories/testing)

jaydeep/laravel-xray
====================

Analyze and understand large Laravel applications through architecture visualization and dead code detection.

25↓100%PHP

Since May 22Pushed 2w agoCompare

[ Source](https://github.com/JaydeepGadhiya/laravel-xray)[ Packagist](https://packagist.org/packages/jaydeep/laravel-xray)[ RSS](/packages/jaydeep-laravel-xray/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel X-Ray
=============

[](#laravel-x-ray)

![Laravel](https://camo.githubusercontent.com/b30a468acd1d53979d9bd905c6838a6fbf172975a381997777533ed397893bec/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d382532422d726564)![PHP](https://camo.githubusercontent.com/ce0c70c519047d0e507604f03e6e8ae6c27bcc072027e899680d9bf93804dc76/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d372e342532422d626c7565)![License](https://camo.githubusercontent.com/f8df3091bbe1149f398a5369b2c39e896766f9f6efba3477c63e9b4aa940ef14/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e)![Stars](https://camo.githubusercontent.com/906b46315bdc3b9d22bbf357a8c30e377ba27c437f923e44f310c0b53007634c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4a617964656570476164686979612f6c61726176656c2d78726179)

Analyze and understand large Laravel applications through architecture visualization and dead code detection.

Laravel X-Ray is a developer tool that scans your application's source code statically — without executing it — and produces detailed reports about your controllers, models, routes, views, services, middleware, and form requests. It detects unused code and visualizes dependency relationships to help you maintain a clean, well-structured codebase.

Features
--------

[](#features)

- Full project health scan with component counts and dead code metrics
- Architecture dependency tree visualization in the terminal and as Mermaid diagrams
- Dead code detection for controllers, models, views, and services/repositories
- Route analysis including named routes, route groups with prefixes, resource and API resource routes
- Model relationship extraction (hasOne, hasMany, belongsTo, belongsToMany, and more)
- Middleware analysis with handle() signature extraction
- Form Request analysis with rules() field name extraction
- Complexity metrics on controllers (method count, lines of code)
- JSON, Markdown, Mermaid (.mmd), and HTML report generation
- Self-contained HTML dashboard powered by Bootstrap 5
- Configurable scan paths via a publishable config file
- `--path` option on all commands to override the scan base path

Requirements
------------

[](#requirements)

- PHP ^7.4 | ^8.0 | ^8.1 | ^8.2 | ^8.3 | ^8.4
- Laravel 8, 9, 10, 11, or 12

Table of Contents
-----------------

[](#table-of-contents)

1. [Installation](#1-installation)
2. [Configuration](#2-configuration)
3. [Commands](#3-commands)
    - [xray:scan](#xrayscan)
    - [xray:architecture](#xrayarchitecture)
    - [xray:deadcode](#xraydeadcode)
    - [xray:report](#xrayreport)
4. [Output Formats](#4-output-formats)
5. [Understanding the Results](#5-understanding-the-results)
6. [Advanced Usage](#6-advanced-usage)
7. [Troubleshooting](#7-troubleshooting)
8. [Contributing](#8-contributing)
9. [License](#9-license)

---

1. Installation
---------------

[](#1-installation)

### Step 1 — Require the package

[](#step-1--require-the-package)

```
composer require jaydeep/laravel-xray
```

### Step 2 — Auto-discovery (Laravel 5.5 and above)

[](#step-2--auto-discovery-laravel-55-and-above)

Laravel automatically discovers and registers the service provider via the `extra.laravel` section in the package's `composer.json`. No manual registration is needed in most setups.

You can verify discovery ran successfully with:

```
php artisan package:discover
```

### Step 3 — Manual registration (optional)

[](#step-3--manual-registration-optional)

If your application has auto-discovery disabled, open `config/app.php` and add the provider to the `providers` array:

```
'providers' => [
    // ...
    Jaydeep\Xray\LaravelXrayServiceProvider::class,
],
```

### Step 4 — Publish the configuration file

[](#step-4--publish-the-configuration-file)

```
php artisan vendor:publish --tag=xray-config
```

This copies `config/xray.php` into your application's `config/` directory so you can customize scan paths and output settings.

---

2. Configuration
----------------

[](#2-configuration)

After publishing, open `config/xray.php`. The file contains three sections.

```
