shell/install/phpcs
2023-04-18 10:22:01 +08:00

33 lines
872 B
Bash
Executable File

#!/bin/bash
##makedesc: Install phpcs + php-cs-fixer
echo
echo "==============================================="
echo "Installing phpcs + php-cs-fixer..."
echo "==============================================="
echo
installed() {
command -v "$1" >/dev/null 2>&1
}
! installed 'php' && echo 'ERROR: You need php to be installed' && exit 1
! installed "composer" && echo "ERROR: You need composer to be installed" && exit 2
COMPOSER_GLOBAL_HOME="$(composer config -g home)"
NEWPATH="export PATH=\"$COMPOSER_GLOBAL_HOME/vendor/bin:\${PATH}\""
cat "$HOME/.profile" | grep -qoh "$NEWPATH" || {
$NEWPATH
echo "$NEWPATH" >> "$HOME/.profile"
}
source "$HOME/.profile"
composer global require squizlabs/php_codesniffer --dev
composer global require friendsofphp/php-cs-fixer --dev
echo
echo "Finish!"
phpcs --version # phpcbf --version
php-cs-fixer --version
echo