Set up Laravel 5.4 with MAMP Pro on MacOS Sierra

Update 28 Nov 2019 – I’m no longer using a Mac (and therefore no longer use MAMP) so can’t vouch for how useful these instructions are.

Update 01 Nov 2017 – Since this post was written Laravel 5.5 and High Sierra have been released and I don’t know if these instructions still work. I recorded the installion steps here as I was setting up Laravel to see if it suited us for a particular project – which it didn’t, so I’m no longer using it (which is not a criticism of Laravel). Although I had gathered together here the steps that worked for me, I’m no expert.

I regularly need to work on WordPress sites locally on my laptop, and for me nothing beats the convenience of MAMP Pro. I’ve also been working on some projects in Laravel, and so needed to add that to my local set up. There are many ways to do this, including Valet and Homestead, both of which are provided by Laravel. However, I didn’t need the power of Homestead and the last time I tried setting up Valet alongside MAMP I ended up with a mess of conflicting versions. In trying to unravel that mess I pretty much totalled my Mac install.

After wiping and reinstalling my Mac, I decided that I would try setting up Laravel to work with MAMP Pro. I couldn’t find an up to date set of instructions that covered every step, so I’ve put this here for my own future reference and in in case it’s useful to anyone else.

I’m using Laravel 5.4 and MAMP Pro 4.1.1 on a clean install of MacOS Sierra 10.12.5.

1. Set bash to use the MAMP version of PHP

The version of PHP that comes preinstalled on MacOS is out of date, so the first thing to do is to make sure that we are using the version installed with MAMP.

export PATH=/Applications/MAMP/bin/php/php7.x.x/bin:$PATH

Replace 7.x.x with the version of PHP you want to use in the terminal.

2. Download and install composer

Laravel uses Composer, so we need to downlad and install that:

curl -s | php

And then move it and set up an alias (see note at the end of step 4). I’m using nano, but use your editor of choice.

sudo mv composer.phar /usr/local/bin/
nano ~/.bash_profile

Add the following to the .bash_profile file.

alias composer="php /usr/local/bin/composer.phar"

Restart the Terminal, and you can run Composer by typing:


3. Install Laravel using Composer

Now we can install and set up Laravel.

composer global require "laravel/installer"

Note: On a clean install, you will be prompted to install the Xcode command line tools (if you haven’t already done so).

4. Make the laravel command available

So that the system can find the Laravel executable we need to run:

echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bash_profile
source ~/.bash_profile

Note: At this stage trying to use the laravel command produced an error saying that composer could not be found. Following advice in this thread on Laracasts I renamed composer.phar to composer and updated the alias.

sudo mv /usr/local/bin/composer.phar /usr/local/bin/composer
alias composer="php /usr/local/bin/composer.phar"

5. Create a Laravel project and make it available via MAMP Pro

Create a new Laravel project

cd ~/Code
laravel new blog

Edit 20 Sep 2017 – Thanks to Sergios who found that these additional commands were needed to get things working.

cd blog
composer install
php artisan key:generate

In MAMP Pro we create a new host (I chose and then point the root to the public folder inside the Laravel project. I also chose to let MAMP Pro create a new database named ‘blog’.

MAMP Pro hosts screen showing set up

Start the MAMP Pro servers and the site should be accessible at

A blank Laravel app running in Safari

6. Using MAMP’s MySQL

If we want to use a database with our app we need to add the details to the .env file:


Note that we’re using localhost rather than If you want to use you need to set MAMP Pro to ‘Allow network access to MySQL’ on the MySQL settings screen.

The MAMP MySQL settings screen

When you run php artisan migrate you may see this error:

SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes

This seems to be caused by the version of MySQL that MAMP Pro uses. Following advice in this thread on Laracasts I added the following to AppServiceProvider.php:

use IlluminateSupportFacadesSchema; //Add this to the top of the file

public function boot()
Schema::defaultStringLength(191); //Add this line to the boot function

If we delete the tables created in the previous attempt and then run php artisan migrate again, it should now work and you should see a message similar to this:

Migration table created successfully.
Migrating: 2014_10_12_000000_create_users_table
Migrated: 2014_10_12_000000_create_users_table
Migrating: 2014_10_12_100000_create_password_resets_table
Migrated: 2014_10_12_100000_create_password_resets_table

Now that everything is set up we should just need to follow steps 5 and 6 each time we want to create a new Laravel project.

7 thoughts on “Set up Laravel 5.4 with MAMP Pro on MacOS Sierra

    1. Hi Amoc,

      Have you set MAMP to use port 80? If not, you will need to access your site at



  1. After the command “laravel new blog” you need to “cd blog” and then “composer install” for the laravel project to work. Else it returns a 500 internal server error if you try to access it.


  2. “sudo mv /usr/local/bin/composer.phar /usr/local/bin/composer
    alias composer=”php /usr/local/bin/composer.phar”

    if you intend to update the alias, shouldn’t it be “alias composer=”php /usr/local/bin/composer” ?


Comments are closed.