Tweet
Share
Send by LINE
B! Bookmarks in Hate-bu
Bookmarks in Pocket
RSS feeds

PHP, How to install composer

PHP composer is a command tool to manage packages.

It is absolutely necessary in the development of PHP programs. We will show you how to install the composer in a simple way with samples and captures.

This is written by a Japanese who can't speak English with the help of translation application. Sorry if it's not good.

The composer command is not included by default in PHP. It needs to be installed separately. The first step is to download the composer.

Download composer.phar file

Composer installation is configured after downloading the composer.phar file.

composer.phar is retrieved from 'https://getcomposer.org/download/'.

Windows has an installer (Composer-Setup.exe). You can get it from the earlier URL.

The site tells you how to download and install it from the command line. You can also download composer.phar by yourself.

Downloading and installing on the command line is the same as on the site, so we will skip it here and just download composer.phar the way it is.

php composer install キャプチャ 1

Download from the link for the version number you want to use.

When downloading on the command line, get the linked URL of the version number and run the command.

Download with Linux commands
curl -o composer.phar https://getcomposer.org/download/1.6.3/composer.phar

How to install composers in Windows10

Run the downloaded exe file. It's easy to follow the installer's instructions.

The work is the same not only in Windows10 but also in earlier versions of Windows.

How to install composers in CentOS

The following method of installing composer on CentOS is to download composers.phar and install it yourself.

There are two installation tasks

  • Creating the composer command
  • Composer command path settings

Creating the composer command

Move the downloaded composer.phar to your desired location. Here we create the composer command in '/home/myuser/bin'.

mv composer.phar ~/bin/composer

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

However, it is common to name the command "composer", so you should work with it.

On Linux, the permissions of the downloaded file are "rw-rw-r--" (664).

Login usersGroupOther users
rw-rw-r--
664
Read, Write
Impossible to execute
Read, Write
Impossible to execute
Read Only
Impossible to execute

This will not allow anyone to run, so change the permissions with the chmod command.

パーミッション変更コマンド
chmod 764 composer

The modified permissions are "rwx-rw-r--".

Login usersGroupOther users
rwxrw-r--
764
Read, Write
Executable
Read, Write
Impossible to execute
Read Only
Impossible to execute

Composer command creation, just rename the composer.phar file

Composer command path settings

Set the environment variable $PATH to allow the composer command to be used anywhere.

Edit .bash_profile.

echo 'export PATH="$PATH:$HOME/bin"' >> .bash_profile

Added ":$HOME/bin".

Run this command to reflect the settings of $PATH.

source .bash_profile

That's all for the installation of the composer command.

RedHat Linux is the same task; on Devian Linux, such as Ubuntu, you should replace the path setting in the Composer command with Devian commands.

Checking for installation

Finally, check for successful installation; the same method for both Linux and Windows.

composer -V

Or, if you have multiple versions of php installed, etc., and you want to specify which php commands to use, do this.

php7 ~/bin/composer -V

(php command names should fit the environment)

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

If you see this result, it has been successfully installed.

Leave a Reply

*