DEV Community

Cover image for INSTALLATION SHELL SCRIPT PHP COMPOSER
shiv
shiv

Posted on

1

INSTALLATION SHELL SCRIPT PHP COMPOSER

!/bin/bash

Check wether composer installed or not:

  if [ ! -x /usr/local/bin/composer ]; then

echo "INSTALLING composer"

Checks the current php version & Install the dependencies:

    CURRENT=$(php -v | head -n 1 | cut -d " " -f 2 | cut -f1-2 -d".")

echo "Y" | apt install curl php$CURRENT-cli php$CURRENT-mbstring git unzip

Change the path to tilde directory & Downloads the composer setup file:

     cd ~

curl -sS https://getcomposer.org/installer -o composer-setup.php

It gets SHA384 composer value:

    HASH=$(curl https://composer.github.io/installer.sig | awk '{print $1}')

Preparing composer installation setup:

    php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Installing Composer:

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Removes the downloaded setup file:

rm -rf ~/composer-setup.php

Message showing successfully installed:

   echo "SUCESSFULLY INSTALLED composer"

During Initial check if composer installed already it shows message:

    else
echo "ALREAY INSTALLED composer"
    fi

Installation shell script for php-composer available in github repo

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay