Installing PHP & Composer & Laravel on a mac

Lots of things went wrong in trying to get PHP + Composer+ Laravel to work on my El Capitan mac and so I document the quick & dirty instructions below.

Step 1: Get homebrew

If you don’t have brew already, everyone’s judging you. EVERYONE.

The missing package manager for macOS.

Make sure you configure your brew path to a non-root directory. I’ve set mine to /usr/local/bin . Also, ensure that /usr/local/bin comes before /usr/bin on your PATH variable. For example, add the line below to your ~/.profile or ~/.bashrc or whatever-you-have.

export PATH=/usr/local/bin:$PATH

Step 2: Get PHP

Use homebrew-php

$ brew tap homebrew/homebrew-php
$ brew install php72

Step 3: Install composer

$ php -r "copy('', 'composer-setup.php');"
$ php composer-setup.php --install-dir=/usr/local/bin --filename=composer

In case you run into old openssl issues, make sure you install openssl with brew and point to your new openssl. Here’s a nifty StackOverflow reference, but be warned that this might not be a good permanent solution:

Homebrew refusing to link OpenSSL
I'm on: OSX 10.11.6, Homebrew version 0.9.9m OpenSSL 0.9.8zg 14 July 2015 I'm trying to play with with dotnetcore and…

Step 4: Install Laravel

$ composer global require "laravel/installer"

Common issues while installing Laravel:

Now, you might face this horrendously unhelpful error, in a vivid red background on your terminal:The process has been signaled with signal “5”.


To see more about what’s happened, run the composer command again with the -vvv flag:

$ composer global -vvv require "laravel/installer"

This will now output a series of commands that are being run. Figure out the last command that was tried before the error comes up again. In my case, this was an svn command. To fix this, take a guess…..yes! Re-install svn via brew!

$ brew install svn

And once that’s done, run the the composer install again and you should be fine.

Step 5: Test it out!

Start a new laravel project:

$ laravel new app

Test it out:

cd app && php artisan serve

Point your browser to localhost:8000 and witness the magick :)

PHP test server serving your Laravel app.

The Hasura platform helps you rapidly add backend APIs to your PHP-Laravel app and instantly deploy it to the cloud. Get started with it here:

Hasura is an open-source engine that gives you realtime GraphQL APIs on new or existing Postgres databases, with built-in support for stitching custom GraphQL APIs and triggering webhooks on database changes.

Tanmai Gopal

Tanmai Gopal

Tanmai is the co-founder of He is a StackOverflow powered fullstack developer and is passionate about making it easier to build things.

Read More