Complete Guide / Isseus / Common Problems: https://github.com/Homebrew/homebrew-php
# Install PHP with PHP-FPM and excluding snmp
brew install -v homebrew/php/php56 --with-fpm --without-snmp
# Set timezone and change other PHP settings
(export USERHOME=$(dscl . -read /Users/`whoami` NFSHomeDirectory | awk -F"\: " '{print $2}') ; sed -i '-default' -e 's|^;\(date\.timezone[[:space:]]*=\).*|\1 \"'$(sudo systemsetup -gettimezone|awk -F"\: " '{print $2}')'\"|; s|^\(memory_limit[[:space:]]*=\).*|\1 512M|; s|^\(post_max_size[[:space:]]*=\).*|\1 200M|; s|^\(upload_max_filesize[[:space:]]*=\).*|\1 100M|; s|^\(default_socket_timeout[[:space:]]*=\).*|\1 600|; s|^\(max_execution_time[[:space:]]*=\).*|\1 300|; s|^\(max_input_time[[:space:]]*=\).*|\1 600|; $a\'$'\n''\'$'\n''; PHP Error log\'$'\n''error_log = '$USERHOME'/Sites/logs/php-error_log'$'\n' $(brew --prefix)/etc/php/5.6/php.ini)
# Fix a pear and pecl permissions problem:
chmod -R ug+w $(brew --prefix php56)/lib/php
# Set the location of php_ini in pear to $(brew --prefix)/etc/php/5.6/pear.conf:
pear config-set php_ini $(brew --prefix)/etc/php/5.6/php.ini system
# The included Opcache extension will speed up your PHP environment dramatically,
# and it's already installed, but needs to be enabled. We'll also bump up the opcache memory limit:
sed -i '' "s|^\(\[opcache\]\)$|\1"\\$'\n'"; Load the opcache extension"\\$'\n'"zend_extension=opcache.so"\\$'\n'"|; s|^;\(opcache\.enable[[:space:]]*=[[:space:]]*\)0|\11|; s|^;\(opcache\.memory_consumption[[:space:]]*=[[:space:]]*\)[0-9]*|\1256|;" $(brew --prefix)/etc/php/5.6/php.ini
# Put the PHP-FPM launchd plist file in place and start PHP-FPM now:
ln -sfv $(brew --prefix php56)/*.plist ~/Library/LaunchAgents
launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.php56.plist
Optional: At this point, if you want to switch between PHP versions, you'd want to stop PHP-FPM by unloading the plist above, run brew unlink php56, repeat all of the above PHP steps for php55/php54/php53, and loading the new plist. No need to touch the Apache configuration at all!
# Installing DNSMasq
brew install -v dnsmasq
# The end result here is that any DNS request ending
# in .dev reply with the IP address 127.0.0.1:
echo 'address=/.dev/127.0.0.1' > $(brew --prefix)/etc/dnsmasq.conf
echo 'listen-address=127.0.0.1' >> $(brew --prefix)/etc/dnsmasq.conf
echo 'port=35353' >> $(brew --prefix)/etc/dnsmasq.conf
# Start DNSMasq
ln -sfv $(brew --prefix dnsmasq)/homebrew.mxcl.dnsmasq.plist ~/Library/LaunchAgents
launchctl load -Fw ~/Library/LaunchAgents/homebrew.mxcl.dnsmasq.plist
# With DNSMasq running, configure OS X to use your
# local host for DNS queries ending in .dev:
sudo mkdir -v /etc/resolver
sudo bash -c 'echo "nameserver 127.0.0.1" > /etc/resolver/dev'
sudo bash -c 'echo "port 35353" >> /etc/resolver/dev'
# To test, the command ping -c 3 foodomain.dev should return results from 127.0.0.1.
# If it doesn't work right away, try turning WiFi off and on (or unplug/plug your ethernet cable), or reboot your system.
brew install homebrew/php/php-cs-fixer
brew install homebrew/php/composer
thanks