This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Victor The Cleaner is a Composer plugin that automatically removes unnecessary files and directories from the vendor directory after composer install or composer update. The plugin analyzes each installed package's composer.json to determine which directories contain actual source files (based on the autoload section) and removes everything else (like tests, documentation, etc.).
- Entry point:
Pluginclass implements Composer'sPluginInterfaceandEventSubscriberInterface - Activation: Automatically runs after
POST_UPDATE_CMDandPOST_INSTALL_CMDevents - Configuration: Users can specify paths to ignore via
extra.cleaner-ignorein their project'scomposer.json
The Cleaner class implements the core cleaning algorithm:
- Package Discovery: Iterates through
vendor/vendor-name/package-namedirectories - Autoload Analysis: Parses each package's
composer.jsonto extract:autoload.psr-0- PSR-0 namespace pathsautoload.psr-4- PSR-4 namespace pathsautoload.classmap- Classmap directories/filesautoload.files- Files to includebin- Binary/executable files
- Exclusion Handling: Removes paths listed in
autoload.exclude-from-classmap - Protection: Always preserves
composer.json,license*,LICENSE*, and.phpstorm.meta.php - Pattern Matching: Uses
fnmatch()for wildcard pattern support (*,?)
Users can configure ignored paths in their project's composer.json:
{
"extra": {
"cleaner-ignore": {
"vendor/package": ["path*", "otherpath"],
"vendor/whole-package": true
}
}
}# Run all tests
composer run tester
# Run specific test file
vendor/bin/tester tests/Cleaner.loadComposerJson.phpt -s -C
# Run tests in a directory
vendor/bin/tester tests/ -s -CTests use Nette Tester (.phpt files) with custom mocks for Composer interfaces defined in tests/mocks.php.
# Run PHPStan analysis
composer run phpstanPHPStan is configured at level 5 and analyzes the src/ directory.
- Use
declare(strict_types=1)in all PHP files - Support PHP 7.1+ (minimum version requirement)
- Follow Nette coding standards
- Use Composer plugin API v1 or v2