OSX PHP Setup 2017


Install Chrome


Install iTerm2


Show Hidden Files in OSX


defaults write com.apple.finder AppleShowAllFiles YES

Then hold down the OPTION key and click the Finder.app icon to restart the Finder

Install Sublime Text 3


Install Homebrew

https://brew.sh/ for instructions

Or just execute in the terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Install PHP 7.1


Or just execute in the terminal

brew update
brew upgrade
brew tap homebrew/dupes
brew tap homebrew/versions
brew tap homebrew/homebrew-php
brew install php71
brew install php71-xdebug
brew install php71-mongodb

Verify that it worked. The following command should should version 7.1

php --version

The php.ini file can be found at


Update xdebug setting to allow remote debugging

vim /usr/local/etc/php/7.1/conf.d/ext-xdebug.ini

# add this line

Add PHP to the bash path

export PATH="$(brew --prefix homebrew/php/php71)/bin:$PATH"

Install Composer

Installs to /usr/local/bin/composer

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be6190fa0355160742ab2e1c88d40d5be660b410') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"

Add composer to the path

vim ~/.bashrc
export PATH="~/.composer/vendor/bin:$PATH"

Install PHPUnit

composer global require phpunit/phpunit

Install Laravel

composer global require laravel/laravel

Install Laravel Envoy

composer global require laravel/envoy

Install Valet

See https://laravel.com/docs/5.4/valet

Valet configures all requests to the *.test domain to be served locally

Valet will install nginx and dsnmasq using homebrew

composer global require laravel/valet
valet install

Now configure Valet to recognize the ~/Sites directory. The park command tells Valet to watch an entire directory

cd ~/Sites
valet park
laravel new blog

Verify that it worked. Visit http://blog.test in the browser

Install MySQL

# install
brew install mysql

# start mysql
brew services start mysql

# set password

# connect to mysql on CLI
mysql -u root -p

The MySQL configuration will be installed to /usr/local/etc/my.cnf

To find the MySQL data directory, run:

mysql -uroot -p -e 'SHOW VARIABLES WHERE Variable_Name LIKE "%dir"'

The default is something like /usr/local/var/mysql

Install MySQL Workbench

Keep an eye on what you're downloading here. There is a free (community) version of MySQL Workbench, but they're try to trick you into downloading packages that are bundled with other software


Open MySQL Workbench and make sure you can connect to localhost:3306

Install PHPStorm


Configure PHPStorm to use PHP7.1

Preferences > Languages & Frameworks
Preferences > Languages & Frameworks > PHP

Set PHP Languages Level = 7.1
Set CLI Interpreter by clicking '...' to open dialog
Click '+' to add a new interpreter
Set Name = PHP7.1
Set PHP Executable = /usr/local/bin/php
Save and return to project

Make sure it works

Create a new project
Create a file called 'test.php'
Write a hello world script
Click 'debug'
If installation was successful, a new window will open with the output

Edit the Keyboard Shortcodes

Copy the default keymap