Package

Leek Laravel Vendor Cleanup

Laravel commands to detect and clean up unchanged vendor-published files (configs, migrations, views, lang files)

Package

leek/laravel-vendor-cleanup

View on GitHub →

Laravel Vendor Cleanup

Detect and clean up unchanged vendor-published files in your Laravel application.

image

This package provides Artisan commands to compare published vendor files (configs, migrations, views, lang files) with their originals in the vendor directory. Find out which files you've modified, which are identical to vendor (cruft), and which files are orphaned from removed packages.

Features

  • ๐Ÿ” Smart Comparison - Automatically strips PHP comments and optionally normalizes whitespace
  • ๐Ÿ“Š Diff Percentages - See exactly how different your files are from vendor originals
  • ๐ŸŽจ Color-Coded Output - Green/yellow/magenta/red based on difference percentage
  • ๐Ÿ—‘๏ธ Safe Cleanup - Optionally delete unchanged files with confirmation
  • ๐Ÿท๏ธ Orphan Detection - Find files from uninstalled packages
  • ๐Ÿ“ฆ Handles Timestamps - Smart migration filename matching (strips timestamps)
  • ๐Ÿ”ง Stub Support - Detects both .php and .php.stub vendor files

Installation

composer require leek/laravel-vendor-cleanup --dev

The package will auto-register via Laravel's package discovery.

Usage

Config Files

Compare published config files with vendor originals:

php artisan vendor-cleanup:config

With options:

# Delete unchanged config files after confirmation
php artisan vendor-cleanup:config --delete

# Normalize whitespace in addition to stripping comments
php artisan vendor-cleanup:config --normalize

Migration Files

Compare published migrations with vendor originals (handles timestamped filenames):

php artisan vendor-cleanup:migration

Lang Files

Compare published language files (supports nested directories and JSON files):

php artisan vendor-cleanup:lang

View Files

Compare published view files in resources/views/vendor/:

php artisan vendor-cleanup:view

Output Categories

Each command categorizes files into four groups:

MODIFIED (color-coded by % different)

Files you've customized, sorted by difference percentage:

  • ๐ŸŸข Green (< 5%) - Very minor changes
  • ๐ŸŸก Yellow (< 15%) - Small changes
  • ๐ŸŸฃ Magenta (< 30%) - Moderate changes
  • ๐Ÿ”ด Red (โ‰ฅ 30%) - Significant changes

UNCHANGED

Files identical to vendor - potential candidates for deletion to reduce cruft.

ORPHANED

Files with no vendor counterpart - either from removed packages or your own application-specific files.

MISSING

Vendor files not yet published locally - available if you need them.

How It Works

  1. Finds all vendor files matching the file type (configs, migrations, etc.)
  2. Strips PHP comments from both vendor and local files for comparison
  3. Optionally normalizes whitespace with --normalize flag
  4. Compares files using SHA256 hashing and similarity algorithms
  5. Categorizes results and displays with color-coded diff percentages

For migrations, the command intelligently strips timestamps from filenames before matching (e.g., 2024_01_15_123456_create_jobs_table.php matches create_jobs_table.php).

Options

All commands support these options:

  • --delete - Interactively delete unchanged files after showing results
  • --normalize - Also normalize whitespace and line endings (comments are always ignored)

Why Use This?

  • Reduce Cruft - Delete unchanged published files and rely on vendor defaults
  • Track Customizations - Quickly see which vendor files you've modified
  • Find Orphans - Identify leftover files from removed packages
  • Upgrade Confidence - Know exactly what you've changed before upgrading packages

Example Output

MODIFIED
+----------------------+------------+
| File                 | Difference |
+----------------------+------------+
| config/services.php  | 65.3%      |
| config/app.php       | 38%        |
| config/database.php  | 9.8%       |
+----------------------+------------+

UNCHANGED (matches vendor)
+------------------------+--------------------+
| File                   | File               |
+------------------------+--------------------+
| config/filesystems.php | config/mail.php    |
| config/cache.php       | config/session.php |
+------------------------+--------------------+

ORPHANED (no vendor counterpart)
+---------------------------+------------------------------+
| File                      | File                         |
+---------------------------+------------------------------+
| config/custom-package.php | config/old-dependency.php    |
+---------------------------+------------------------------+

MISSING (not published locally)
+------------------------------------+-------------------------------------+
| File                               | File                                |
+------------------------------------+-------------------------------------+
| vendor/package/config/optional.php | vendor/another/config/settings.php  |
+------------------------------------+-------------------------------------+

Done.

Requirements

  • PHP 8.2+
  • Laravel 11.x or 12.x

License

MIT

Leek Laravel Vendor Cleanup Related Articles

Detect and Clean Up Unchanged Vendor Files with Laravel Vendor Cleanup image

Detect and Clean Up Unchanged Vendor Files with Laravel Vendor Cleanup

Read article
Streamline Pipeline Cleanup with Laravel's finally Method image

Streamline Pipeline Cleanup with Laravel's finally Method

Read article
Delete Expired Sessions in Laravel With a Scheduled Command image

Delete Expired Sessions in Laravel With a Scheduled Command

Read article
Improved HTTP Client URL Parameter Merging in Laravel 12.33 image

Improved HTTP Client URL Parameter Merging in Laravel 12.33

Read article
Remove "final" keywords from classes and methods in vendor packages with Unfinalize image

Remove "final" keywords from classes and methods in vendor packages with Unfinalize

Read article
Exclude Vendor and Default Commands in `php artisan dev` image

Exclude Vendor and Default Commands in `php artisan dev`

Read article

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech

Let your users buy domains without leaving your app

If your Laravel app gives users a site, a storefront, or a workspace, theyโ€™ll eventually want their own domain. The name.com API lets them search, register, and connect one without leaving your product. Itโ€™s a clean REST API, so Laravelโ€™s HTTP client is all you need.

Let your users buy domains without leaving your app

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum