Skip to content

Composer Cheat Sheet

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you. Composer is not a package manager in the traditional sense.

All composer commands you install may need to use php composer.phar in the composer installation folder instead of the regular composer.

Package Management

Command Description
composer install Install everything in composer.json
composer install laravel Install a specific package
composer install laravel --dry-run Simulate the installation and show what will happen
composer install laravel --no-scripts Skip scripts defined in the composer.json file

Update

Command Description
composer update Update all packages
composer update laravel Update a specific package
composer update vendor/* Update all packages under a specific vendor folder
composer update --lock Only update the lock file hash without updating any package

Dependencies

Command Description
composer require laravel Add a new package to composer.json and install it
composer require laravel --dev Add a new package to require-dev and install it

Removal

Command Description
composer remove laravel Remove a package from composer.json and uninstall it