Skip to content

Instantly share code, notes, and snippets.

@immanuelpotter
Last active June 11, 2018 18:08
Show Gist options
  • Select an option

  • Save immanuelpotter/bf47fbf54304f87598fe1209d15f6c72 to your computer and use it in GitHub Desktop.

Select an option

Save immanuelpotter/bf47fbf54304f87598fe1209d15f6c72 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: www.github.com/immanuelpotter
# Usage: run this script in your root project dir.
# run: "php composer.phar --create-project --prefer-dist laravel/laravel <project_name>"
# run: "cd <project_name> && php ../composer.phar install"
#check if you've got the package already
if_installed(){
PACKAGE="$1"
PACKAGE_LIVES="$(dirname $(which ${PACKAGE}))"
if [[ $? -eq 0 ]] ; then
echo "Package $PACKAGE is installed at $PACKAGE_LIVES"
else
yum install -y $PACKAGE
fi
}
#install php
php(){
if_installed php
}
#install composer
composer(){
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
}
#use EPEL repo to find mcrypt - no bin to check,
epel(){
EPEL_EXISTS="$(find /etc/yum.repos.d/ -name "*epel*")"
if [[ -z $EPEL_EXISTS ]] ; then
yum install -y epel-release
else
echo "Looks asif epel is already enabled. Good!"
fi
}
#install laravel dependencies
laravel(){
yum install -y php-{mbstring,mcrypt,pdo}
}
main(){
php
composer
epel
laravel
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment