How to install Composer download Composer
Be sure to install PHP correctly before installing it. Open a command-line window and perform a php -v
check to see if the version number is output correctly.
Open the command line and execute the following command sequentially to install the latest version of Composer:
- Download the installation script-
composer-setup.php
-to the current directory. The script that executes the first command composer-setup.php
will simply detect the php.ini
parameters in the settings, give a warning if some parameters are not set correctly, and then download the latest version of the composer.phar
file to the current directory.
php -r "copy(‘https://install.phpcomposer.com/installer‘, ‘composer-setup.php‘);"
2. Perform the installation process.
php composer-setup.php
3. Delete the installation script.
php -r "unlink(‘composer-setup.php‘);"
Partial installation
After the process of downloading Composer is done correctly, you can composer.phar
copy the files to any directory (such as the project root directory) and then use the Composer with the php composer.phar
instructions!
Global Installation
The global installation is to install Composer PATH
under the path contained in the system environment variable, and then execute the command directly in the command composer
-line window.
Mac or Linux system:
Open a command-line window and execute the following command to move the previously downloaded composer.phar
file to the /usr/local/bin/
directory:
sudo mv composer.phar /usr/local/bin/composer
Windows System:
- Locate and go to the installation directory of PHP (and the instructions you execute on the command line
php
should be the same set of PHP).
- will be
composer.phar
copied to PHP under the installation directory, that is, and php.exe
in the same level directory.
- Create a new file in the PHP installation directory
composer.bat
and save the following code to this file.
@php "%~dp0composer.phar" %*
Finally reopen a command-line window and try it out to composer --version
see if the version number is correctly printed.
About upgrading Composer
Composer upgrade is not able to use our image to speed up the download, and must be connected to the Composer foreign official website of the server downloaded the upgrade files, some times it will cause the speed of the upgrade is very slow or even failure.
Here's an easy way to do this:
If your system already has a normal use of Composer, indicating that the system environment is compliant, then only need to download a new Composer file and overwrite the original file.
First you need to determine the existing Composer installation directory, and then download the file via the link below composer.phar
(copy the following address to the browser address bar to download directly),
https://install.phpcomposer.com/composer.phar
Overwrite the file that you downloaded earlier with the composer.phar
files that are already installed on your system composer.phar
. Note that it is possible to rename the installation with the composer.phar
composer
same name overlay.
Composer installation Tutorial Windows System | Linux Systems | Mac System