A Composer plugin that snapshots tracked files and directories from vendor/ into a committed project directory. After each composer install or composer update, any changes in tracked paths become visible via git diff.
composer require --dev setono/dependency-trackerScaffold a config file:
composer dependency-tracker:initThis creates dependency-tracker.php in your project root. Open it and add the vendor paths you want to track:
<?php
declare(strict_types=1);
use Setono\DependencyTracker\Config;
return static function (Config $config): void {
// Track a full directory recursively
$config->track('vendor/sylius/sylius/src/Sylius/Bundle/CoreBundle/Migrations');
// Track a directory but only *.php files, non-recursively
$config->track('vendor/acme/package/config')
->filter('*.php')
->recursive(false);
// Track a single file
$config->track('vendor/doctrine/migrations/src/Version/MigrationStatusCalculator.php');
// Change the output directory (default: .dependency-snapshots)
$config->setOutputDir('.dependency-snapshots');
};Run composer install or composer update to trigger the first snapshot. The tracked files are copied into .dependency-snapshots/ where they are visible to git:
git diff
git statusdependency-tracker.php-- the config file- The entire
.dependency-snapshots/directory -- the snapshots themselves
Do not add .dependency-snapshots/ to .gitignore.
On every composer install or composer update the plugin:
- Reads
dependency-tracker.phpfrom the project root - For each tracked directory: deletes the snapshot copy entirely and re-copies all matching files. This means additions, modifications, and deletions in vendor are all visible in
git diff. - For each tracked file: copies it to the mirrored location. If the source file was removed from vendor, the snapshot copy is deleted automatically.
Filters are matched against filenames (not full paths) using fnmatch(). Multiple patterns use OR logic:
$config->track('vendor/acme/package/src')
->filter('*.php', '*.xml'); // includes .php and .xml filesBy default directories are traversed recursively. To track only the files directly inside a directory:
$config->track('vendor/acme/package/config')
->recursive(false);| Method | Returns | Description |
|---|---|---|
track(string $path) |
Track |
Register a path relative to project root |
setOutputDir(string $dir) |
self |
Set output directory (default: .dependency-snapshots) |
| Method | Returns | Default | Description |
|---|---|---|---|
filter(string ...$patterns) |
self |
No filter (all files) | Glob patterns matched against filenames |
recursive(bool $recursive) |
self |
true |
Whether to descend into subdirectories |
If a tracked path does not exist in vendor/ at run time, the plugin emits a warning and continues processing the remaining tracks. This is not fatal.
composer remove setono/dependency-trackerThen delete dependency-tracker.php and .dependency-snapshots/ from your project.