Skip to content

Composer Cheat Sheet

Composer is a dependency management tool for PHP 5.3+. It allows you to declare the libraries your project depends on, and it will install them for you in your project. Composer is not a package manager.

For all composer commands you install, you 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 package
composer install laravel --dry-run Simulate installation and show what would 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 folder
composer update --lock Only update the lock file hash, without updating any packages

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

Remove

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