Cheat Sheets & Quick References

Composer Command Line Quick Reference

Keep common Composer commands close at hand for adding packages, installing locked dependencies and inspecting project requirements.

Overview

Composer commands are used throughout the PHP development lifecycle. This quick reference covers common operations; consult the official CLI documentation for all options and version-specific behavior.

Common commands

composer init
composer require vendor/package
composer require --dev vendor/package
composer install
composer update vendor/package
composer show
composer outdated
composer validate
composer dump-autoload

Application workflow

Use composer require to add a dependency and composer require --dev for development-only tools. Commit the lock file for applications. On deployment, prefer composer install so the versions in the lock file are installed consistently.

Safety notes

Review package source, maintenance activity, licensing and security advisories. Avoid unreviewed broad updates on production systems. Keep Composer credentials and private repository tokens out of public files and version control.

Official resource

Composer CLI documentation: https://getcomposer.org/doc/03-cli.md