Overview
Third-party packages accelerate development but also introduce maintenance and security responsibilities. A repeatable dependency workflow makes installations reproducible and updates reviewable.
Commit the lock file
For an application, commit composer.lock. Use composer install to reproduce the locked dependency set. Run composer update intentionally in development, review the lock-file changes and run tests before deployment.
Separate runtime and development packages
Use require for runtime dependencies and require --dev for tools such as test runners and static analyzers. Production deployments can install without development packages when the application does not need them at runtime.
Review updates
Check package maintenance, supported PHP versions, changelogs and breaking changes. Avoid blindly updating every dependency on a production server. Test upgrades in staging and keep a rollback plan.
Audit vulnerabilities
Use Composer's audit functionality and monitor upstream security advisories. An audit is one signal, not a complete security review: abandoned packages, malicious releases and vulnerable application usage still require attention.
Official references
Composer basic usage Composer CLI
Commit the lock file
For an application, commit both composer.json and composer.lock. The lock file records the resolved dependency versions so development, staging and production install a consistent set. Use composer install for deployments; reserve composer update for a reviewed dependency change.
Review updates before deployment
Read release notes, check supported PHP versions, inspect transitive changes and run tests. Use Composer's audit functionality where supported by the installed Composer version, and review advisories from trusted package sources. Do not assume a package is safe solely because it is popular.
Reduce supply-chain risk
Prefer maintained packages with clear ownership, release history and documented security practices. Avoid abandoned dependencies where a maintained alternative exists. Review Composer scripts and plugins because they can execute code during installation.
Deploy reproducibly
Build and test the dependency set in staging, deploy the same lock file to production and keep a rollback path. Do not run broad dependency updates directly on the live server without review. Document who owns critical packages and how emergency security updates are handled.