Composer Cheat Sheet
Composer Cheat Sheet
Installation Configuration
Command Description
Download Composer from https://getcomposer.org/download/ and follow the instructions.
composer config sort-packages true Sort packages in composer.json alphabetically
Enable bash autocompletion:
© Nic Wortel, Software Consultant & Trainer - Last updated on August 3, 2023 - Find more cheat sheets at https://nicwortel.nl/cheat-sheets
Version constraints Repositories
Constraint Description Command Description
1.0.2 Exactly version 1.0.2 composer config repositories.foo Add a new repository named foo with the given URL
composer <url> as a Composer repository
>=1.0.2 Version 1.0.2 or higher
composer config repositories.foo vcs Add a new repository named foo with the given URL
>=1.0.2 <1.1.0 Version 1.0.2 or higher but lower than 1.1.0 <url> as a VCS repository
Version 1.0.2 or higher but lower than 1.1.0 or composer config repositories.foo vcs Add a new GitHub repository named foo/bar as a
>=1.0.2 <1.1.0 || >=1.2.0
version 1.2.0 or higher git@github.com:foo/bar.git VCS repository
1.0 - 2.0 Version 1.0 to 2.0 (including 1.0 and 2.0) composer config repositories.foo path Add a new repository named foo with the given
1.0.* Version 1.0 with any patch version <path> path as a path repository
© Nic Wortel, Software Consultant & Trainer - Last updated on August 3, 2023 - Find more cheat sheets at https://nicwortel.nl/cheat-sheets