Installation of latest Composer

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

Composer requires PHP 5.3.2+ to run. A few sensitive php settings and compile flags are also required, but when using the installer you will be warned about any incompatibilities.

First need to have php installed, on Debian You can to do with one command :

apt-get install php

Now create script for install :

cd ~
nano install_composer_local.sh

And put this script:

#!/bin/bash

function inst_composer(){

  php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

  if [ ! -d "$HOME/.local/bin" ]; then
    mkdir -p "$HOME/.local/bin"
  fi

  php composer-setup.php --install-dir=$HOME/.local/bin --filename=composer
  php -r "unlink('composer-setup.php');"

}

function conf_composer(){

  if [ -z $(echo $PATH | grep $HOME/.local/bin) ]; then
      echo -e '\nPATH="$HOME/.local/bin:$PATH"' >> $HOME/.bashrc
  fi

  if [ -z $(echo $PATH | grep $HOME/.composer/vendor/bin) ]; then
      echo -e '\nPATH="$HOME/.config/composer/vendor/bin:$PATH"' >> $HOME/.bashrc
  fi

  export PATH="$HOME/.local/bin:$PATH"
  export PATH="$HOME/.config/composer/vendor/bin:$PATH"

}

cd ~
inst_composer
conf_composer

 

Now add permission for excute bash file:

chmod +x install_composer_local.sh

 

All is ready for start installation :

./install_composer_local.sh

After running script just reopen console and check composer with :

composer --version

Enjoy in new composer !!!

 

Add ping

Trackback URL : https://www.jurisic.org/trackback/6

Page top