I’ve spent most of my time working with PHP in Windows. Recently, I switched to a mac and I ran into some issues getting it ready for PHP web development. I wrote this guide to help newcomers moving from Windows to a mac to get up and running as fast as possible.
If you need any help or get stuck, please leave a comment and I'd be glad to help!
What I’ve Installed
Everything I mention here is completely free —- no purchase or registration required.
Here’s what’s I’ve installed for my "30-minute macOS PHP stack":
Here’s a step-by-step guide that should get you up and running in ~30 minutes.
- Open a Terminal
- Install Homebrew
- Install PHP
- Install Composer
- Install Laravel Valet
- Update the Paths File
- Setup Laravel Valet
- Install the Laravel Installer
- Install DBngin
- Create your App
1. Open a Terminal
Open a new terminal window by pressing ⌘ + Space, and typing
2. Install Homebrew
Paste the following command in the terminal window to install Homebrew:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Lots of things will appear during the Homebrew install. Wait until it completely finishes before running any further commands and continuing on with this guide.
3. Install PHP
When completed, in the same terminal window, install PHP using Homebrew:
brew install php
4. Install Composer
Then run the following to install Composer using Homebrew:
brew install composer
Once completed, run:
cp /usr/local/Cellar/composer/*/bin/composer /usr/local/bin/composer
This copies the composer binary into a location that is accessible globally in our terminal.
5. Install Laravel Valet
Using our newly installed Composer, we will install Laravel Valet globally:
composer global require laravel/valet
6. Update the Paths File
Now we will edit our
/etc/paths file to be able to run our globally installed composer packages from any terminal window.
To edit this file, copy and paste the following in a terminal window:
sudo nano /etc/paths
This command will ask you for your account password to continue.
Then, navigate to the bottom of the file using your keyboards arrow keys, press Enter to create a new line and paste in:
stevebaumanin the above path with your own macOS username, which can be found by running
id -unin the same terminal window.
It should look like this once done:
Then press ⌘ + X to close the file, type Y to save changes and press Enter.
To ensure you can execute composer globablly, run:
You should see:
7. Setup Laravel Valet
To get Laravel Valet setup, we must run:
Running this will prompt you for your macOS password.
With that completed, we will create a folder in our mac that will house all of our PHP apps.
I created a folder named
Sites in my
Once you have your own folder created,
cd to it:
And run Laravel Valets "park" command to register it as a location of web applications:
This command never needs to be execute again. New sub-directories will automatically be detected by Laravel Valet.
8. Install the Laravel Installer
To be able to generate new Laravel apps easily so we can get to work, we will install the Laravel Installer by running the following command:
composer global require laravel/installer
9. Install DBngin
Visit https://dbngin.com and download the latest version. Once downloaded, install it as you would any macOS application. After you've installed it, open it and you should see this:
Click the + button, select "MySQL", and version "5.7.23" from the dropdowns, enter
mysql for the name:
Then click the Create button, and you should be greeted with:
Simply click the "Start" button to start the MySQL service.
If you restart your mac, you will likely need to start MySQL manually after logging in.
10. Create your App
We're done -- all we need to do now is scaffold a new Laravel app, and we're off.
cd to our
Then generate a new Laravel app:
laravel new my-app
Now visit your new app in any browser http://my-app.test:
Congratulations, you're awesome! 🎉