Overview
Composer manages PHP project dependencies and generates an autoloader for installed packages. These commands cover common application workflows.
Frequently used commands
composer init
composer require vendor/package
composer require --dev vendor/package
composer install
composer update vendor/package
composer show
composer show --outdated
composer validate
composer dump-autoload
Lock file workflow
For applications, commit composer.lock so deployments install the dependency versions selected during development. Use composer install in deployment workflows. Run updates deliberately, review the lock-file changes and test the application.
Production deployment
Development dependencies can be excluded with the appropriate no-dev install option. Keep Composer credentials and repository tokens outside the public web root and source control.