php: How to install composer

Other language site
ja ja
Google Translate
  • -

    シェア
  • ---

    LINEで送る
  • -

    はてなブックマーク
    ブックマーク
  • -

    pocket
  • -

    rss
php logo

php composer is a command tool to manage packages.

Be sure to use composer command to develop php program.

In order to develop php program efficiently it is absolutely not a tool to remove.

Since the composer command does not have the standard function of php, it must be installed separately.

Download composer.phar file

The composer installation is done by downloading and setting composer.phar file.

The composer.phar file is obtained from here (https://getcomposer.org/download/).

For Windows, an installer (Composer-Setup.exe) is provided. You can get it from the above download site. You can install it easily according to the instructions of the installer.

In the explanation of the page where you get the composer.phar file, you download it from the command line, but you can download and use the composer.phar file directly from the web page.

The download method on the command line is as described in https://getcomposer.org/download so we will not explain it here.

Let's try to download the direct composer.phar file.

php composer install capture 1

Click on the version number link to use and download.

When downloading from the command line, obtain the url of the link destination from the link of the version number and execute the command.

wget https://getcomposer.org/download/1.6.3/composer.phar

Create composer command

In the installation method from the command line of https://getcomposer.org/download, it is possible to specify the download destination as an option and create the command file.

If you download the composer.phar file yourself, do it because you need to work on them yourself.

Move the composer.phar file to the desired location. Here we create composer command in "/home/myuser/bin".

$ mv composer.phar ~/bin/composer

This work is not absolutely necessary work. It is unnecessary if you use the command name as "composer.phar".

However, since it is common to use it as "composer" as the command name, we recommend that you work.

Path setting of composer command

Set $PATH so that composer command can be used anywhere.

It is set with .bash_profile.

PATH=$PATH:$HOME/.local/bin:$HOME/bin

":$HOME/bin" part has been added.

source .bash_profile

Execute. This is a command to reflect the edited $PATH.

This completes the installation work of composer command.

composer -V

or

php composer -V

Then,

Composer version 1.6.2 2018-01-05 15:28:41

The composer command can be used if it is displayed.

SNS also distributes articles.
Leave a Reply

*

If you like this article, share it!