PHPackages                             crumbls/laravel-detect-unused-files - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. crumbls/laravel-detect-unused-files

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

crumbls/laravel-detect-unused-files
===================================

A Laravel package to detect unused files in your project

0.0.1(11mo ago)17MITPHPPHP ^8.3

Since May 20Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/Crumbls/laravel-detect-unused-files)[ Packagist](https://packagist.org/packages/crumbls/laravel-detect-unused-files)[ RSS](/packages/crumbls-laravel-detect-unused-files/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Laravel Detect Unused Files
===========================

[](#laravel-detect-unused-files)

This package helps identify unused PHP files in your Laravel application by tracking which files are actually used during application execution.

Why does this exist?
--------------------

[](#why-does-this-exist)

I was asked to help migrate part of a huge app to a smaller app. Copying and pasting created tons of artifacts and unused files. We didn't want to expose anything that isn't critical to this app, so I created this package to find unused app PHP files.

[![Latest Version on Packagist](https://camo.githubusercontent.com/0b37ef62e8327c59fea0ffa291b14c8a7d3a6d5ce3a890c5487e4bfb892cf3b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6372756d626c732f6c61726176656c2d6465746563742d756e757365642d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/crumbls/laravel-detect-unused-files)[![Total Downloads](https://camo.githubusercontent.com/278d672ff7c0d77c6a51f36a68722a946575c43b998e2fba931a75f47e66ee88/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6372756d626c732f6c61726176656c2d6465746563742d756e757365642d66696c65732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/crumbls/laravel-detect-unused-files)

⚠️ Development Use Only
-----------------------

[](#️-development-use-only)

> **Warning**: This package is intended for **development environments only**. It adds additional database queries and file tracking operations that may impact application performance in production.

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

[](#requirements)

- PHP 8.3 or higher
- Laravel 12.0 or higher
- A Laravel application with a database connection configured

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

[](#installation)

You can install the package via composer:

```
composer require crumbls/laravel-detect-unused-files --dev
```

After installing the package, you need to run the migrations:

```
php artisan migrate
```

This will create the necessary `file_usage` table in your database to track file usage.

How It Works
------------

[](#how-it-works)

This package works by:

1. Tracking all files in your application's `app` directory
2. Recording which files are actually loaded during application execution
3. Allowing you to query for files that have never been loaded (potentially unused)

Usage
-----

[](#usage)

### Step 1: Add App Files to Tracking

[](#step-1-add-app-files-to-tracking)

First, add all your application's PHP files to the tracking system:

```
php artisan files:add-app
```

This command will scan your `app` directory for PHP files and add them to the tracking database.

### Step 2: Use Your Application

[](#step-2-use-your-application)

For accurate results, you should use your application normally after running the above command. Browse through different pages and features of your application to ensure that all necessary files are loaded.

The more comprehensive your browsing, the more accurate the results will be. Try to cover:

- All major features
- Admin areas
- Different user roles
- API endpoints
- Console commands
- Scheduled tasks

### Step 3: List Unused Files

[](#step-3-list-unused-files)

After using your application, you can check for unused files:

```
php artisan files:list-unused
```

This will display a list of PHP files that were never loaded during your application usage.

#### Additional Options

[](#additional-options)

You can filter the results with various options:

```
# Limit the number of results
php artisan files:list-unused --limit=10

# Filter by a filename pattern
php artisan files:list-unused --pattern=Controller

# Only show files added more than X days ago
php artisan files:list-unused --days=7
```

Best Practices
--------------

[](#best-practices)

For the most accurate results:

- Run this in a development environment that mimics your production setup
- Execute all your application's automated tests to cover edge cases
- Consider running the tracker over multiple days of normal development use
- Re-run `files:add-app` periodically to capture newly added files

How The Package Tracks Files
----------------------------

[](#how-the-package-tracks-files)

The package performs the following operations:

1. Records all PHP files in your `app` directory
2. Uses PHP's `get_included_files()` function to track file usage during request execution
3. Updates the database on application shutdown to mark loaded files as "used"
4. Provides commands to query the database for unused files

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

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

License
-------

[](#license)

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

Credits
-------

[](#credits)

- [Crumbls](https://github.com/Crumbls)

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance50

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

358d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3020753?v=4)[Chase C. Miller](/maintainers/chasecmiller)[@chasecmiller](https://github.com/chasecmiller)

---

Top Contributors

[![chasecmiller](https://avatars.githubusercontent.com/u/3020753?v=4)](https://github.com/chasecmiller "chasecmiller (2 commits)")

### Embed Badge

![Health badge](/badges/crumbls-laravel-detect-unused-files/health.svg)

```
[![Health](https://phpackages.com/badges/crumbls-laravel-detect-unused-files/health.svg)](https://phpackages.com/packages/crumbls-laravel-detect-unused-files)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M158](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

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