Tool cheatsheet
Composer 2 Cheatsheet
Manage PHP dependencies, autoloading, scripts and project creation with Composer 2.
Setup
- Check the Composer version — Print the installed Composer version.
- Update Composer — Update Composer itself to the latest release.
- Create a composer.json — Create composer.json interactively in the current folder.
- Create a project from a package — Create a new project from a package, here a Laravel application.
- Diagnose problems — Check your system and Composer setup for common problems.
- Validate composer.json — Check composer.json for errors and warnings.
Dependencies
- Install dependencies — Install the exact versions listed in composer.lock, or resolve and write a lock file if none exists.
- Add a package — Add a package to composer.json and install it.
- Add a development package — Add a package needed only during development, such as a test framework.
- Add a package at a version — Require a version constraint. ^7.0 allows any 7.x release at or above 7.0.
- Remove a package — Remove a package from composer.json and the vendor folder.
- Update all packages — Update dependencies to the newest versions allowed by composer.json, and rewrite composer.lock.
- Update one package — Update a single package and the dependencies it needs.
- Find outdated packages — List installed packages that have newer versions.
- Find outdated direct dependencies — Limit the list to packages you require directly.
- List installed packages — List installed packages with their versions.
- Show the dependency tree — Print installed packages and their dependencies as a tree.
- Find why a package is installed — List the packages that depend on a given package.
- Find why a version can't be installed — Explain which requirements block installing a package or version.
- Check for security advisories — Check installed packages for known vulnerabilities.
Autoloading and production
- Regenerate the autoloader — Rebuild the autoload files after adding classes or changing the autoload section.
- Optimize the autoloader — Generate a class map for faster autoloading in production.
- Install for production — Install without development packages and with an optimized autoloader.
- Run a script — Run a script defined in the scripts section of composer.json.
- Allow a plugin — Composer 2.2 and later ask you to allow plugins explicitly. Allow one by name.
- Clear Composer's cache — Delete the packages Composer has downloaded and cached.
- Install a tool globally — Install a package into your global Composer folder, for command-line tools.
Related cheatsheets
- Ansible 2 cheatsheet — Run ad-hoc commands and playbooks, manage inventories, roles, collections and secrets with Ansible.
- Argo CD 3 cheatsheet — Install Argo CD, define Applications declaratively, and manage sync, diffs, history and rollbacks with the argocd CLI.
- AWS CLI 2 cheatsheet — Configure credentials and manage S3, EC2, Lambda, logs, containers and secrets with the AWS CLI v2.
- Azure CLI 2 cheatsheet — Sign in and manage resource groups, VMs, web apps, storage, Kubernetes, registries and secrets with the az command.
- Bash and Linux 5 cheatsheet — Everyday shell and Linux commands for files, searching text, permissions, processes and servers.
- Claude API cheatsheet — Call Claude from Python, TypeScript or curl: messages, streaming, thinking, tools, structured output, caching, batches and error handling.