The last notes
All English-language materials have been translated fully automatically using the Google service
Downloading and Installing Composer on Linux
Composer provides an installer written in PHP. We have to download it, make sure it isn't corrupted, and then use it to install Composer.
Make sure you are in your home directory and then download the installer with curl
:
cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php
Next, make sure the installer hash matches the SHA-384 hash for the latest installer in Composer Public Keys / Signatures . Copy the hash from this page and save it as a command line variable:
HASH=544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061
Be sure to replace the last hash with the one highlighted in red.
Now run the following PHP script to make sure the install script is safe to run:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
You should see the following output:
Installer verified
If you see Installer corrupt
, you need to download the install script again and re-verify that you are using the correct hash. Run the command and check the installer again. Once the installer has successfully verified, you can proceed.
To install composer
globally, use the following command, which will download and install composer
as a system-wide composer command in the / usr / local / bin directory
:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
The output should look like this:
All settings correct for using Composer
Downloading...
Composer (version 1.6.5) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
To test the installation, run the command:
composer
You should get similar output with Composer version and arguments.
______
/ ____/___ ____ ___ ____ ____ ________ _____
/ / / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__ ) __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
/_/
Composer version 1.6.5 2018-05-04 11:44:59
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--profile Display timing and memory usage information
--no-plugins Whether to disable plugins.
-d, --working-dir=WORKING-DIR If specified, use the given directory as working directory.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
. . .
This means that the Composer dependency manager has been successfully installed and is available system-wide.
Note: if you prefer to have separate Composer executables for each project you host on this server, you can install locally for each project. NPM users should be familiar with this approach. This method is also useful when the system user does not have system-wide rights to install software.
To do this, use the php composer-setup.php
command. This will generate a composer.phar
file in the current directory, which can be executed using the ./composer.phar
command.
Original:
Installing composer using the Windows command line
Start the Windows
console and use the cd
command to navigate to the desired folder.
Execute the following commands one by one:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '756890a4488ce9024fc62c56153228907f1545c228516cbf63f885e036d37e9a59d27d63f46af1d4d07ee0f76181c7d3') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
If the installation was not performed, then the checksum has changed. Go to link and get new installation commands
Comments