Composer & Dependency Management
debt(d3/e3/b5/t5)
Closest to 'default linter catches the common case' (d3). The term's detection_hints.tools lists composer, dependabot, and snyk — these catch missing composer.lock, outdated dependencies, and CVEs automatically. Dependabot and composer audit are commonly integrated into CI pipelines and catch the most common mistakes (missing lock file, security vulnerabilities) without specialized configuration.
Closest to 'simple parameterised fix' (e3). The quick_fix indicates straightforward remediation: commit composer.lock, switch from 'composer update' to 'composer install', add --no-dev flag, run 'composer audit'. These are configuration/command changes rather than one-line code patches, but they don't require multi-file refactoring — mostly CI pipeline and .gitignore adjustments.
Closest to 'persistent productivity tax' (b5). Composer applies to all PHP contexts (web, cli, queue-worker) per applies_to, making it load-bearing infrastructure. Every deployment, every new dependency, every CI run interacts with this choice. However, it's a well-understood standard tool rather than a custom architectural decision, so it doesn't quite reach b7's 'strong gravitational pull' that shapes every change.
Closest to 'notable trap' (t5). The misconception explicitly states developers believe committing vendor/ is safer, when actually composer.lock is the correct artefact. This is a documented gotcha that most PHP developers eventually learn, but it contradicts the intuitive 'commit everything needed to run' instinct. The common_mistakes reinforce this — running 'update' vs 'install' and using wildcard versions are traps that aren't obvious from the command names.
Also Known As
TL;DR
Explanation
Composer resolves, downloads, and autoloads PHP packages from Packagist and other repositories. The composer.lock file records the exact version and hash of every installed package — committing it to version control ensures every developer and deployment uses identical dependencies. Run composer audit regularly to check for known security vulnerabilities in dependencies, use --no-dev in production installs, and verify the integrity of packages with hash checks. The vendor directory should never be committed to version control.
Common Misconception
Why It Matters
Common Mistakes
- Not committing composer.lock to version control — different machines install different versions.
- Running composer update in production — can install breaking changes mid-deploy.
- Using * or latest version constraints — installs any future version including breaking changes.
- Including require-dev dependencies in production builds by not using --no-dev flag.
Code Examples
// composer.json with wildcard versions — unpredictable installs:
{
"require": {
"vendor/package": "*",
"another/lib": "@latest"
}
}
# Install dependencies from composer.lock (reproducible)
$ composer install --no-dev --optimize-autoloader
# Add a package
$ composer require ramsey/uuid
# Require dev dependency (not installed in production)
$ composer require --dev phpunit/phpunit
# Audit for known CVEs
$ composer audit
# Autoload dump — after adding classes manually
$ composer dump-autoload --optimize
# composer.json — key fields
{
"require": {"php": ">=8.2", "ext-pdo": "*"},
"autoload": {"psr-4": {"App\\\\": "src/"}},
"scripts": {
"test": "phpunit",
"lint": "phpcs --standard=PSR12 src/"
}
}