- Introduction#
- Dependency management#
- System Requirements#
- Installation — Linux / Unix / macOS#
- Downloading the Composer Executable#
- Locally#
- Globally#
- Installation — Windows#
- Using the Installer#
- Manual Installation#
- Using Composer#
- Download Composer Latest: v2.0.12
- Notable Installer Options
- —install-dir
- —filename
- —version
- Download channels
- Manual Download
Introduction#
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.
Dependency management#
Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with «packages» or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor ) inside your project. By default, it does not install anything globally. Thus, it is a dependency manager. It does however support a «global» project for convenience via the global command.
This idea is not new and Composer is strongly inspired by node’s npm and ruby’s bundler.
- You have a project that depends on a number of libraries.
- Some of those libraries depend on other libraries.
- Enables you to declare the libraries you depend on.
- Finds out which versions of which packages can and need to be installed, and installs them (meaning it downloads them into your project).
- You can update all your dependencies in one command.
See the Basic usage chapter for more details on declaring dependencies.
System Requirements#
Composer requires PHP 5.3.2+ to run. A few sensitive php settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.
To install packages from sources instead of plain zip archives, you will need git, svn, fossil or hg depending on how the package is version-controlled.
Composer is multi-platform and we strive to make it run equally well on Windows, Linux and macOS.
Installation — Linux / Unix / macOS#
Downloading the Composer Executable#
Composer offers a convenient installer that you can execute directly from the command line. Feel free to download this file or review it on GitHub if you wish to know more about the inner workings of the installer. The source is plain PHP.
There are in short, two ways to install Composer. Locally as part of your project, or globally as a system wide executable.
Locally#
To install Composer locally, run the installer in your project directory. See the Download page for instructions.
The installer will check a few PHP settings and then download composer.phar to your working directory. This file is the Composer binary. It is a PHAR (PHP archive), which is an archive format for PHP which can be run on the command line, amongst other things.
Now run php composer.phar in order to run Composer.
You can install Composer to a specific directory by using the —install-dir option and additionally (re)name it as well using the —filename option. When running the installer when following the Download page instructions add the following parameters:
Now run php bin/composer in order to run Composer.
Globally#
You can place the Composer PHAR anywhere you wish. If you put it in a directory that is part of your PATH , you can access it globally. On Unix systems you can even make it executable and invoke it without directly using the php interpreter.
After running the installer following the Download page instructions you can run this to move composer.phar to a directory that is in your path:
If you like to install it only for your user and avoid requiring root permissions, you can use
/.local/bin instead which is available by default on some Linux distributions.
Note: If the above fails due to permissions, you may need to run it again with sudo.
Note: On some versions of macOS the /usr directory does not exist by default. If you receive the error «/usr/local/bin/composer: No such file or directory» then you must create the directory manually before proceeding: mkdir -p /usr/local/bin .
Note: For information on changing your PATH, please read the Wikipedia article and/or use your search engine of choice.
Now run composer in order to run Composer instead of php composer.phar .
Installation — Windows#
Using the Installer#
This is the easiest way to get Composer set up on your machine.
Download and run Composer-Setup.exe. It will install the latest Composer version and set up your PATH so that you can call composer from any directory in your command line.
Note: Close your current terminal. Test usage with a new terminal: This is important since the PATH only gets loaded when the terminal starts.
Manual Installation#
Change to a directory on your PATH and run the installer following the Download page instructions to download composer.phar .
Create a new composer.bat file alongside composer.phar :
Add the directory to your PATH environment variable if it isn’t already. For information on changing your PATH variable, please see this article and/or use your search engine of choice.
Close your current terminal. Test usage with a new terminal:
Using Composer#
Now that you’ve installed Composer, you are ready to use it! Head on over to the next chapter for a short demonstration.
Found a typo? Something is wrong in this documentation? Fork and edit it!
Composer and all content on this site are released under the MIT license.
Download Composer Latest: v2.0.12
To quickly install Composer in the current directory, run the following script in your terminal. To automate the installation, use the guide on installing Composer programmatically.
This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory. The 4 lines above will, in order:
- Download the installer to the current directory
- Verify the installer SHA-384, which you can also cross-check here
- Run the installer
- Remove the installer
WARNING: Please do not redistribute the install code. It will change with every version of the installer. Instead, please link to this page or check how to install Composer programmatically.
Notable Installer Options
—install-dir
You can install composer to a specific directory by using the —install-dir option and providing a target directory. Example:
php composer-setup.php —install-dir=bin
—filename
You can specify the filename (default: composer.phar ) using the —filename option. Example:
php composer-setup.php —filename=composer
—version
You can install composer to a specific release by using the —version option and providing a target release. Example:
php composer-setup.php —version=1.0.0-alpha8
The installer provides more options for specific environments, use the —help option to see all of them.
Download channels
By default the installer and composer self-update will download the latest stable version only. You may select a different download channel though.
If you would like to help test pre-release versions you can use the —preview flag on either the installer or self-update.
For snapshot builds, which are done from the latest Composer commit, you can use the —snapshot flag.
To programmatically install specific major versions you can use the —1 or —2 flag. Example:
php composer-setup.php —preview
Manual Download
If you prefer to download the phar manually, here are the available versions:
2.0.12 | 2021-04-01 | sha256 82ea8c1537cfaceb7e56f6004c7ccdf99ddafce7237c07374d920e635730a631 | changelog |
2.0.11 | 2021-02-24 | sha256 d6eee0d4637f4bd82bdae098fceda300dcb3ec35bf502604fbe7510933b8f952 | changelog |
2.0.10 | 2021-02-23 | sha256 72a5a68d12f315d74d931462413f7e114cd77b4be1a6b9494141dda93410751a | changelog |
2.0.9 | 2021-01-27 | sha256 8e91344a5ca2fc0fb583c50f195a1f36918908561c4ea3d6f01a4ef01c3b8560 | changelog |
2.0.8 | 2020-12-03 | sha256 2021f0d52b446e0efe3c548cc058ab5671fa38cdbcf814e7911c7e9d71d61538 | changelog |
2.0.7 | 2020-11-13 | sha256 0a060e8caf1d5cde55c4562fd68369b08cf231b8fd30da9c8f994b111557ebe9 | changelog |
2.0.6 | 2020-11-07 | sha256 e5e39d8fa699ddb09844f6b4388280ff2c805fef0a7c26580c5bbc91ac35091b | changelog |
2.0.5 | 2020-11-06 | sha256 e786d1d997efc1eb463d7447394b6ad17a144afcf8e505a3ce3cb0f60c3302f9 | changelog |
2.0.4 | 2020-10-30 | sha256 c3b2bc477429c923c69f7f9b137e06b2a93c6a1e192d40ffad1741ee5d54760d | changelog |
2.0.3 | 2020-10-28 | sha256 5d377e9b504dc9f6c9228d81c321ba85290512cdb396a12d3708b0cd30d2e20c | changelog |
2.0.2 | 2020-10-25 | sha256 5e122edd0f2a4fb01172b6b1c156b3d252d9205105b4ad169a4b09913ba6a859 | changelog |
2.0.1 | 2020-10-24 | sha256 4b4b118cc54662e4813ba86efb215fdb19c5b29944c5919b4f2803c915aa2234 | changelog |
2.0.0 | 2020-10-24 | sha256 139657aa2b37867800292724145e3c4895f7755d845758b403dc329d17bdd285 | changelog |
2.0.0-RC2 | 2020-10-14 | sha256 337b69c2fbf56c158538b7521bea6b09c42a29d39c4b8b25e55d21ba1440f807 | changelog |
2.0.0-RC1 | 2020-09-10 | sha256 0d3a60be9515c87d6c061899ddaa23aa1476b34f7c0f75e562a928f58019f973 | changelog |
2.0.0-alpha3 | 2020-08-03 | sha256 56acbd0b4c3314dac87a04fe44fe55bdfc117da38dfee8fd29528093d1e704bf | changelog |
2.0.0-alpha2 | 2020-06-24 | sha256 6490fc59e48bf1ea5f3301cde071a56dc63e9a7dbb5540a94501bec570cabd5d | changelog |
2.0.0-alpha1 | 2020-06-03 | sha256 22ff90cd50d331bfab5c4eef35b5290a83a5bf7fadf52d47b72aade01e893920 | changelog |
1.10.21 | 2021-04-01 | sha256 1477d56da4a941de4203982c05b8a371ee4a9f2bb88a69f1b31c75d6bd6b8306 | changelog |
1.10.20 | 2021-01-27 | sha256 e70b1024c194e07db02275dd26ed511ce620ede45c1e237b3ef51d5f8171348d | changelog |
1.10.19 | 2020-12-04 | sha256 688bf8f868643b420dded326614fcdf969572ac8ad7fbbb92c28a631157d39e8 | changelog |
1.10.18 | 2020-12-03 | sha256 322d769490aedb12f95fa5f32e2c20f5753b07700a259472db427ddcf843884b | changelog |
1.10.17 | 2020-10-30 | sha256 6fa00eba5103ce6750f94f87af8356e12cc45d5bbb11a140533790cf60725f1c | changelog |
1.10.16 | 2020-10-24 | sha256 e494bb438e44b9e4782c16940b229a8c46ea8a3baa9b908bf9db310cd0171ee2 | changelog |
1.10.15 | 2020-10-13 | sha256 a69df12e86a0a18fbedfc91a33d5f9acc5cf939576e0258326074fc1b2ee1aea | changelog |
1.10.14 | 2020-10-13 | sha256 ec8c97badf06c1d51bdc2fe16d75bc7306a08a112b12a34563ff8da5d6621db7 | changelog |
1.10.13 | 2020-09-09 | sha256 5ca7445cfd48dd27c5a84aa005a47b4d9fd91132313830609875df3a6973708f | changelog |
1.10.12 | 2020-09-08 | sha256 ad32ebf620bffabe1e680802da610e8ba2eea4ecbbd76df973ce47d2ff192cba | changelog |
1.10.11 | 2020-09-08 | sha256 6c4e61d21d2dd2c30da5e8dc244b302939678abaca82196eb0cf5ed7c9f4b143 | changelog |
1.10.10 | 2020-08-03 | sha256 8f16aa77b1236ed40855d8d141c0a939d108a939c8e73f9f32eadd3f05f181b9 | changelog |
1.10.9 | 2020-07-16 | sha256 70d6b9c3e0774b398a372dcb7f89dfe22fc25884e6e09ebf277286dd64cfaf35 | changelog |
1.10.8 | 2020-06-24 | sha256 4c40737f5d5f36d04f8b2df37171c6a1ff520efcadcb8626cc7c30bd4c5178e5 | changelog |
1.10.7 | 2020-06-03 | sha256 b94b872729668de5b5fbf62f16ff588d2a23480dda88c0e45cb43b721b75ae29 | changelog |
1.10.6 | 2020-05-06 | sha256 29bdac1bda34d8902b9f9e4f5816de08879b8f3fafad901e4283519cdefbee7b | changelog |
1.10.5 | 2020-04-10 | sha256 d5f3fddd0be28a5fc9bf2634a06f51bc9bd581fabda93fee7ca8ca781ae43129 | changelog |
1.10.4 | 2020-04-09 | sha256 642df93a823f7d45ea544b337542a405ceb3e6c0b7b04d48574801ca364bfa9a | changelog |
1.10.3 | 2020-04-09 | sha256 2e162689cbb198943be915247c3cb34ba7810f9ee3c608288c6775668b22a98d | changelog |
1.10.2 | 2020-04-09 | sha256 1faea4a90f74692a765181a3025ada7c8ed1a8f87ca3fae229471876841d8484 | changelog |
1.10.1 | 2020-03-13 | sha256 1831f266580f221189dc04d4b58d7fc50c934ffc3a0eca89ecb4a53aa44867e2 | changelog |
1.10.0 | 2020-03-10 | sha256 8ced713bde2d89468c3385588daf27dc6fc7bc7619f95239068608d303700b09 | changelog |
1.10.0-RC | 2020-02-14 | sha256 58c5d690ec1ee348efed8d59e529dd322bca1d4f588d08eb20100f1c855bade4 | changelog |
1.9.3 | 2020-02-04 | sha256 551655c2fc81f4106508f42bbc4b24eabd34b022b13bc1e7d9642bf483d0a7d4 | changelog |
1.9.2 | 2020-01-14 | sha256 58753998712ae435915a452d701ae28a9389653bbf36b3b6adf24e03d90a9467 | changelog |
1.9.1 | 2019-11-01 | sha256 1f210b9037fcf82670d75892dfc44400f13fe9ada7af9e787f93e50e3b764111 | changelog |
1.9.0 | 2019-08-02 | sha256 c9dff69d092bdec14dee64df6677e7430163509798895fbd54891c166c5c0875 | changelog |
1.8.6 | 2019-06-11 | sha256 b66f9b53db72c5117408defe8a1e00515fe749e97ce1b0ae8bdaa6a5a43dd542 | changelog |
1.8.5 | 2019-04-09 | sha256 4e4c1cd74b54a26618699f3190e6f5fc63bb308b13fa660f71f2a2df047c0e17 | changelog |
1.8.4 | 2019-02-11 | sha256 1722826c8fbeaf2d6cdd31c9c9af38694d6383a0f2bf476fe6bbd30939de058a | changelog |
1.8.3 | 2019-01-30 | sha256 5733ae9516e9185b7c3328d16dac75f3475f8ef137572dfb497f0f298157df33 | changelog |
1.8.2 | 2019-01-29 | sha256 489025eb489a2a70b8cdd7acd53f530e7be22a342b8c971a9d73091b898c7aed | changelog |
1.8.1 | 2019-01-29 | sha256 ded65cb32160648146a264eaf4b4919308b3f1fdc8e38a0dde8406396860dfab | changelog |
1.8.0 | 2018-12-03 | sha256 0901a84d56f6d6ae8f8b96b0c131d4f51ccaf169d491813d2bcedf2a6e4cefa6 | changelog |
1.7.3 | 2018-11-01 | sha256 bc6cbcd2c0fbc03c7ab87442b5f1fbc9407f0b9900bddc10d755bdc81bbe7b6e | changelog |
1.7.2 | 2018-08-16 | sha256 ec3428d049ae8877f7d102c2ee050dbd51a160fc2dde323f3e126a3b3846750e | changelog |
1.7.1 | 2018-08-07 | sha256 1c0e95dc3f33985f9eeabb6f57896c0f9d46b7c9e70ad7bf2210a5508869a8fa | changelog |
1.7.0 | 2018-08-03 | sha256 88068af567884a6266ef255d3d17053f583c9074dc75161b7a35eda8e553849a | changelog |
1.7.0-RC | 2018-07-24 | sha256 902d97573567b72a07754b20c64949ba878bb85571c0d3e5c6ddae66ffb278c0 | changelog |
1.6.5 | 2018-05-04 | sha256 67bebe9df9866a795078bb2cf21798d8b0214f2e0b2fd81f2e907a8ef0be3434 | changelog |
1.6.4 | 2018-04-13 | sha256 8d0d9246f68532cc8fd6a47a58d195f0c849d26430f93c397a3176fc2d971ded | changelog |
1.6.3 | 2018-01-31 | sha256 52cb7bbbaee720471e3b34c8ae6db53a38f0b759c06078a80080db739e4dcab6 | changelog |
1.6.2 | 2018-01-05 | sha256 6ec386528e64186dfe4e3a68a4be57992f931459209fd3d45dde64f5efb25276 | changelog |
1.6.1 | 2018-01-04 | sha256 71b6701ab75c93d0986b3e906d9d2586f0ae1b3e611583210a9542021861f581 | changelog |
1.6.0 | 2018-01-04 | sha256 45031b4ae95bb6f4bdd33704a1932bfb8b56f5a590ee16b4946f481903c28fd1 | changelog |
1.6.0-RC | 2017-12-19 | sha256 fbbc2a8085331976ff08a7920230a30e38b847b1f3bfbae54e1c0ea6676b2fae | changelog |
1.5.6 | 2017-12-18 | sha256 25e75d72818c4f1d46b3ae47a8deaaf4ef25c87198329d4a6ee53601b00459e5 | changelog |
1.5.5 | 2017-12-01 | sha256 8ef8c4fb73c8cc1e950119799aec31e0ae5913dab8dd8f53d9c2e3985ac3ad2b | changelog |
1.5.4 | 2017-12-01 | sha256 b85461bb94c1abf1ccaa6832a7992c08d2d851f844c575626766554bd96de8c3 | changelog |
1.5.3 | 2017-11-30 | sha256 f50e3b1d7daa6afc532341e52735db32819310cb2f63cb166f69dc7e074a657e | changelog |
1.5.2 | 2017-09-11 | sha256 c0a5519c768ef854913206d45bd360efc2eb4a3e6eb1e1c7d0a4b5e0d3bbb31f | changelog |
1.5.1 | 2017-08-09 | sha256 2745e7b8cced2e97f84b9e9cb0f9c401702f47cecea5a67f095ac4fa1a44fb80 | changelog |
1.5.0 | 2017-08-08 | sha256 8a9f570241f1f858529c13f4d09d38b3379fe1a1d27cb74bc71093f1a8f1b225 | changelog |
1.4.3 | 2017-08-06 | sha256 03fc40c59e1e5711d61d6f340e9159ac94701107e0fe05aa795b611d004bdf35 | changelog |
1.4.2 | 2017-05-17 | sha256 6b1945c3ee477f12be508a5bb41a5025d57de5510bcf94855ae6a4d59f3d86f4 | changelog |
1.4.1 | 2017-03-10 | sha256 abd277cc3453be980bb48cbffe9d1f7422ca1ef4bc0b7d035fda87cea4d55cbc | changelog |
1.4.0 | 2017-03-08 | sha256 2e2d851f9ff3c9b526bfecc2e7f020cc7a74d8f64fbb403061d13f23f091a137 | changelog |
1.3.3 | 2017-03-08 | sha256 2a63562e756a27b0f0391461bcf06306b3cfdaef54beec3728dde94e94a99d96 | changelog |
1.3.2 | 2017-01-27 | sha256 6a4f761aa34bb69fca86bc411a5e9836ca8246f0fcd29f3804b174fee9fb0569 | changelog |
1.3.1 | 2017-01-07 | sha256 f3e0faddf49039edf40ab62c497e0926286e8871a50228fd90ea91dcebbd15c3 | changelog |
1.3.0 | 2016-12-23 | sha256 92ce3125cae2015c5c1f7657e78a6e239ff47b714eb1418288abf45d55f3be27 | changelog |
1.3.0-RC | 2016-12-11 | sha256 e21e98f17932a49a00bfbb1397b62c79f4e22937b09ff4d2fec92fca82381011 | changelog |
1.2.4 | 2016-12-06 | sha256 3c900579659b79a4e528722e35bd160c86090e370e9cb41cc07c7a22c674c657 | changelog |
1.2.3 | 2016-12-01 | sha256 3378c1422bffa09c29714aefd3240b963ce7731e71ae8894d9c7991101325cb8 | changelog |
1.2.2 | 2016-11-03 | sha256 c6ae4e099351233f5f82ade9738475eec6587aadf9ffe66fec4c350b329fbb32 | changelog |
1.2.1 | 2016-09-12 | sha256 c2e04040b807a8530e5c83de56bdaaf63a0f183f8fd449bbe6e41f660e647427 | changelog |
1.2.0 | 2016-07-18 | sha256 dc80131545ed7f7b1369ae058824587f0718892f6a84bd86cfb0f28ab5e39095 | changelog |
1.2.0-RC | 2016-07-04 | sha256 1e1dddd7fbccd5de565cfb0429020d4f9f95a6207b48952d939aadcf891d2fdc | changelog |
1.1.3 | 2016-06-26 | sha256 4349ef555c8478b8fe148b10957bc40d696ce7b8cdeb7d50d3d684a854dca5cc | changelog |
1.1.2 | 2016-05-31 | sha256 7af2409080619e2ba98e78d7675710c23acf2ccf088d4439a4f79c33ed85c505 | changelog |
1.1.1 | 2016-05-17 | sha256 7f26efee06de5a1a061b6b1e330f5acc9ee69976d1551118c45b21f358cbc332 | changelog |
1.1.0 | 2016-05-10 | sha256 d8e1d21081b7076dfc9a570620e082111ab196dabd83780e50025c52d62b801c | changelog |
1.1.0-RC | 2016-04-29 | sha256 31e771ed24f3db45019a073fe9e43a6a8e75249962012955cd105ebec0a08100 | changelog |
1.0.3 | 2016-04-29 | sha256 78c5c0e3f41dcd4d6ee532d9ae7e23afa33bdd409d8824dff026f3991d6ad70a | changelog |
1.0.2 | 2016-04-21 | sha256 264673ccee900b22192605b8c74ecb77c45a5197347edacd142699866c478f4c | changelog |
1.0.1 | 2016-04-18 | sha256 de069dae8c7bf01adedc925d3ac2358e5318a1b05580b001aa04e585fa55d8c0 | changelog |
1.0.0 | 2016-04-05 | sha256 1acc000cf23bd9d19e1590c2edeb44fb915f88d85f1798925ec989c601db0bd6 | changelog |
1.0.0-beta2 | 2016-03-27 | sha256 128f8c7ad49a71e4abda885ca52c603e370d5cbed85479ae1eab4a58a398a6a4 | changelog |
1.0.0-beta1 | 2016-03-03 | sha256 4344038a546bd0e9e2c4fa53bced1c7faef1bcccab09b2276ddd5cc01e4e022a | changelog |
1.0.0-alpha11 | 2015-11-14 | sha256 47347f16d366145eafb45d2e800012dc80cb8fc08d1d299849825c51465381ac | changelog |
1.0.0-alpha10 | 2015-04-14 | sha256 9f2c7d0364bc743bcde9cfe1fe84749e5ac38c46d47cf42966ce499135fd4628 | changelog |
1.0.0-alpha9 | 2014-12-07 | sha256 33ef1c07649bc1e135e73f0944415753233faf803cff493006f8bd9e744ff1f4 | changelog |
1.0.0-alpha8 | 2014-01-06 | sha256 1c73973d7cfb73f3e6b425b943a3e1459f5199984f37f008c48cf2b671dd3f2b | changelog |
1.0.0-alpha7 | 2013-05-04 | sha256 8fb4ac2da72856394b4bdd65d470797b23c27d496821a456046527fe6ccc9786 | changelog |
1.0.0-alpha6 | 2012-10-23 | sha256 eacac2a637de230e6091fdb45e893705049f929c271a5dc90d2c9eac0f44c5c4 | changelog |
1.0.0-alpha5 | 2012-08-18 | sha256 7e0fd9248b0f03ddbb3d20d4be2d130fecce432b66ff96f6e99a906f85d82796 | changelog |
1.0.0-alpha4 | 2012-07-04 | sha256 b1f5737a3916ad34f74566be51d21f3597d9aebaa382d942c5bda4d1338008b3 | changelog |
1.0.0-alpha3 | 2012-05-13 | sha256 7cac0a430602342a60949e580d49fefde57b5ff53d4b488e18d78aabf57eef19 | changelog |
1.0.0-alpha2 | 2012-04-03 | sha256 acc373396d66d0083231a9d90691886e894ccca778398258e44c3dab60db2363 | changelog |
1.0.0-alpha1 | 2012-03-01 | sha256 dd703cf132b2a6bb9b2a407ef8834cab9f433cf04f252f1a125b09f8f7a46912 | changelog |
Composer and all content on this site are released under the MIT license.