Skip to content

Instantly share code, notes, and snippets.

@ksemel
Created January 23, 2017 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksemel/3372bc815143c5659d23ae220c0995ea to your computer and use it in GitHub Desktop.
Save ksemel/3372bc815143c5659d23ae220c0995ea to your computer and use it in GitHub Desktop.
Install PHP CodeSniffer and other dependencies
#!/bin/bash
# Install PHP Code Sniffer and related modules
TMP_PATH=/tmp/
BIN_PATH=/usr/local/bin/
cd $TMP_PATH
# PHPCS
# PHP Code Sniffer
# https://github.com/squizlabs/PHP_CodeSniffer/wiki
if [ -z "`which phpcs`" ]; then
sudo curl -LsS https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -o /usr/local/bin/phpcs
sudo chmod a+x ${BIN_PATH}phpcs
fi
# Fix the pathing for Code Sniffer if you get an error
#sudo mkdir -p /Library/Server/Web/Config/php
#sudo touch /Library/Server/Web/Config/php/local.ini
#echo 'include_path = ".:'`pear config-get php_dir`'"' | sudo tee -a /Library/Server/Web/Config/php/local.ini
# PHPMD
# PHP Mess Detector
# https://phpmd.org/
if [ -z "`which phpmd`" ]; then
sudo curl -LsS http://static.phpmd.org/php/latest/phpmd.phar -o ${BIN_PATH}phpmd
sudo chmod a+x ${BIN_PATH}phpmd
fi
# PHP CS FIXER
# PHP Coding Standards Fixer
# https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar
if [ -z "`which php-cs-fixer`" ]; then
sudo curl -LsS https://github.com/FriendsOfPHP/PHP-CS-Fixer/releases/download/v2.0.0/php-cs-fixer.phar -o ${BIN_PATH}php-cs-fixer
sudo chmod a+x ${BIN_PATH}php-cs-fixer
fi
# PHPCBF
# PHP Code Beautifier and Fixer
# https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically#using-the-php-code-beautifier-and-fixer
if [ -z "`which phpcbf`" ]; then
sudo curl -LsS https://squizlabs.github.io/PHP_CodeSniffer/phpcbf.phar -o ${BIN_PATH}phpcbf
sudo chmod a+x ${BIN_PATH}phpcbf
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment