Last active
June 11, 2018 23:20
-
-
Save bfintal/f3e8f5445940c30a24d4ca155b9d1ae3 to your computer and use it in GitHub Desktop.
WordPress development tools that I need in MacOSX. At the end of this, you can have linter-phpcs working with WP standards (helpful for Atom) and scss compilation among others. Note to self: will still need to install xcode & command line tools.
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 | |
# FILE="/tmp/out.$$" | |
# GREP="/bin/grep" | |
# Make sure only normal users can run our script since we have sudos in the commands. | |
if [ "$(id -u)" == "0" ]; then | |
echo "This script must be run as a normal user" 1>&2 | |
exit 1 | |
fi | |
# Make sure this can only run outside VirtualBox / VVV | |
if [ "$(dmesg | grep VirtualBox || echo '1')" != '1' ]; then | |
echo "This script must be run outside VirtualBox / VVV" 1>&2 | |
exit 1 | |
fi | |
# Install Homebrew (needed for gettext & node) | |
which brew || ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
# Install node.js | |
npm -v || sudo brew install node | |
# Install pear if not installed | |
pear list || sudo php /usr/lib/php/install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin | |
# Install Ruby Sass | |
# We need it for compiling sass (gulp-ruby-sass) | |
gem list -i sass || sudo gem install sass | |
# Install Gulp | |
gulp -v || sudo npm install -g gulp | |
# Install PHP Code Sniffer. | |
# Use 2.9 because WordPress Standards doesn't yet support 3.0 as of 06/22/2017. | |
# PHPCS 3.0 support at ticket: https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/996 | |
pear list PHP_CodeSniffer || sudo pear install PHP_CodeSniffer-2.9.1 | |
# Install WordPress Standards for PHPCS | |
# https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards | |
# Note that PHPCS < 3.0 uses PHP/Standards folder, PHPCS 3.0 uses PHP/src/Standards folder. | |
# When 3.0 is supported, add the "src" folder. | |
rm -fR wpcs | |
git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs && sudo cp -R wpcs/WordPress* $(pear config-get php_dir)/PHP/CodeSniffer/Standards && rm -fR wpcs && phpcs -i | |
# Install WordPress Standards for PHPCompatibility. | |
# https://github.com/wimg/PHPCompatibility | |
# Note that PHPCS < 3.0 uses PHP/Standards folder, PHPCS 3.0 uses PHP/src/Standards folder. | |
rm -fR PHPCompatibility | |
git clone -b master https://github.com/wimg/PHPCompatibility.git PHPCompatibility && sudo cp -rf PHPCompatibility $(pear config-get php_dir)/PHP/CodeSniffer/Standards && rm -fR PHPCompatibility && phpcs -i | |
# Sometimes PHPCS fails (MacOSX Yosemite), make it work! | |
# From http://viastudio.com/configure-php-codesniffer-for-mac-os-x/ | |
phpcs -i || ( 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 ) | |
# PHPCS may fail if the include_path still isn't right (MacOS Sierra, not upgraded version) | |
# From https://github.com/squizlabs/PHP_CodeSniffer/issues/1441#issuecomment-299339060 | |
# Send a note for manual insertion: | |
ls /etc/php.ini.default && ls /etc/php.ini || ( ls /etc/php.ini.default && sudo cp /etc/php.ini.default /etc/php.ini && echo 'MANUALLY ADD THIS TO YOUR /etc/php.ini:' && echo 'include_path = ".:'`pear config-get php_dir`'"' || echo 1 ) | |
# Install gettext for tranlations | |
brew list gettext || brew install gettext |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment