Downloading the Composer Executable#

21.06.2019

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:

php composer-setup.php --install-dir=bin --filename=composer

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:

mv composer.phar /usr/local/bin/composer

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 Google.

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 composerfrom 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:

C:\bin>echo @php "%~dp0composer.phar" %*>composer.bat

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 Google.

Close your current terminal. Test usage with a new terminal:

C:\Users\username>composer -V
Composer version 1.0.0 2016-01-10 20:34:53

Using Composer#

Now that you’ve installed Composer, you are ready to use it! Head on over to the next chapter for a short and simple demonstration.

No Comments
prev
Leave a comment

about us

We have an experienced and dedicated team equipped with strong expertise on technical development, technological changes and industrial systems. We are committed to provide the best and most economical solutions to our valued customers.

With over 10 years of experience and technical knowledge, we are here to produce various advanced industrial applications based on different needs of technology. Our team of professionals and supporting personnel are ready to develop infrastructure related IT projects, general internal system and site revamping for our customers. We build what is right for our customers.

office location
+852 91375571
Unit 960, 9/F, Building 19W No. 19 Science Park West Avenue Hong Kong Science Park, Pak Shek Kok N.T., Hong Kong
info@hazedawn.com
opening hours
Mon - Fri
8:00 - 21:00
Saturday
8:00 - 18:00
Sunday
9:00 - 17:00
辦公時間
禮拜一 - 禮拜五
8:00 - 21:00
禮拜六
8:00 - 18:00
禮拜天
9:00 - 17:00
Subscribe our newsletter