Paul Underwood
PaulundSoftware Engineer

Composer Cheatsheet

Install Dependencies

composer install
composer install --dry-run

Add Packages

composer require vendor/package
composer require vendor/package --dev

Update Packages

composer update
composer update --with-dependencies
composer update vendor/package
composer update vendor/*
composer update --lock

Remove Packers

composer remove vendor/package

Update Autoloader

composer dumpautoload -o

Versioning

"require": {
    // Exact version to 1.5.4
    "vendor/package": "1.5.4",
        
    // Greater or lower bounds
    "vendor/package": ">=1.5.0", // Anything above 1.5.0
    "vendor/package": "<1.5.0", // Anything below 1.5.0
    
    // Wildcard
    "vendor/package": "1.5.*", // >=1.5 <1.6
    
    // Next significant release
    "vendor/package": "~1.5", // >=1.5 <2.0.0 
    "vendor/package": "~1.5.2", // >=1.5.2 <1.6.0
    
    // Next release, major version fixed
    "vendor/package": "^1.5.2", // >=1.5.2 <2.0.0 
    "vendor/package": "^0.5.2", // >=0.5.2 <0.6.0
}