Created
December 15, 2013 14:43
-
-
Save sk8terboi87/7973799 to your computer and use it in GitHub Desktop.
Check PHP And Its Related Modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
php_version(){ | |
echo `php -r '$version = phpversion(); | |
echo sprintf("\033[34m%s\033[37m", "$version");'` | |
} | |
php_compability_check() { | |
echo `php -r ' if (version_compare(PHP_VERSION, "5.4", "<")) { | |
echo sprintf("\033[31m%s\033[37m", "Upgrade PHP!! PHP 5.4 or Greater!"); | |
};'` | |
} | |
php_modules(){ | |
echo `php -m ` | |
} | |
php_verify_version(){ | |
echo `php -r 'if (extension_loaded("'$1'")) { | |
$version = phpversion("'$1'"); | |
echo sprintf("\033[32m%s\033[37m", "✓ $version"); | |
} else { | |
echo sprintf("\033[31m%s\033[37m", "✘ Missing"); | |
} '` | |
} | |
check_set(){ | |
[[ -x "$1" ]] && echo 1 || echo 0 | |
} | |
sad_print(){ | |
printf '\e[31m%s\e[0m \e[1m%s\e[0m %s\n' "✘" "$1" "$2" | |
} | |
# This prints ✓ in green, | |
# rest in bold. | |
happy_print(){ | |
printf '\e[32m%s\e[0m \e[1m%s\e[0m %s\n' "✓" "$1" "$2" | |
} | |
# print extra descriptions for failure states | |
desc_print(){ | |
printf "\t%s \e[47m\e[0;35m%s\e[0m %s\n" "$1" "$2" "$3" | |
} | |
mongo=$(check_set $mongofile) | |
git=$(check_set $gitfile) | |
mysql=$(check_set $mysqlfile) | |
curl=$(check_set $curlfile) | |
mongofile=$(command -v mongo) | |
mysqlfile=$(command -v mysql) | |
curlfile=$(command -v curl) | |
gitfile=$(command -v git) | |
PHP=$(which php) | |
if [ -e "$PHP" ]; then | |
echo $(php_compability_check) | |
if [ "$gitfile" = 0 ]; then | |
echo happy_print "Git Okay!" | |
fi | |
echo "PHP Version: " $(php_version) | |
echo "PDO MySql: " $(php_verify_version "pdo_mysql") | |
echo "MySql: " $(php_verify_version "mysql") | |
echo "Mongo: " $(php_verify_version "mongo") | |
echo "AOP: " $(php_verify_version "aop") | |
printf '\e[32m%s\e[0m \e[1m%s\e[0m %s\n' "If everything seems okay, [wget http://localhost/shape-it/composer.json and do composer install]" | |
else | |
echo "Install PHP and Continue." | |
exit 1 | |
fi | |
# php -r '$foo = phpversion();' | |
# php -r '$foo = get_defined_constants(); var_dump($foo);' | |
# php -r "phpinfo();" | awk '/^Loaded|^Scan/ {print $NF}' | |
# php -r '$version = phpversion("extensionName");var_dump($version);' | |
# PHP | 5.3/Missing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment