How to install Laravel on Mac using MAMP?

Laravel is a powerful framework to speed PHP web development, MAMP is a handy GUI to allow quick and easy testing of websites on OS X. Smash them together and you get quick and easy web development on OS X.

We got a great tip to try Laravel, a framework for building database-driven sites using PHP. Key among the features that attracted us was the Eloquent ORM for managing database models, blade templating and integration with Composer for dependency management.

Being a hip and trendy start up type operation, we all develop on Macs. So I needed a neat tool for running a web server with PHP and MySQL on OS X. I’ve been using MAMP for this purpose for a few years now, which provides a full Apache/MySQL/PHP stack, the Pro version of which gives me a heap of tools for configuring multiple sites (including automatic management of my hosts file).

The trick is to get the two working together, which can be a little tricky, primarily due to one of Laravel’s strengths, it’s integration with Composer. This post is intended as a guide for getting a Laravel site up and running on MAMP.

These instructions assume you already have MAMP up and running and know how to set up a site.

There are a few little pitfalls when installing. First of all, it’s important to make sure you’re using the same PHP on the commant line as in MAMP.


1. Set PATH for PHP

Find out where your PHP executable is located:

Check this is the most recent version and under /Applications/MAMP

Add this path to ~/.bash_profile

If you wish to use PHPUnit, you should also modify your php.ini for MAMP as listed on this Stackoverflow question:

2. Configure Composer

Next comes the installation of Composer. Luckily, this is fairly straightforward using a Terminal, if you know the right commants.

First, we need to download and run the Composer installer. Change into your desired working directory (we’ll move the download later) and execute:

This creates composer.phar, which you can run from your working directory as follows:

To make it a bit easier to run, let’s move composer.phar and set up an alias:

Where vim is your favourite editor. Add the below line to your bash profile:

If you re-open Terminal, you can run Composer quite simply:


3. Install Laravel using Composer

With Composer installed, you can quickly install a Laravel instance using the following commant at a terminal:

This will create a full project with the given name in the working directory.


4. Configure your Laravel site in MAMP

To configure a Laravel site in MAMP, you just need to point the root of the site to the publicdirectory of your Laravel project. This step will vary depending on whether you have MAMP or MAMP Pro running.

You will also need to configure write permissions under app/storage.


5. Continue with Quick Start

From now on you’re all set. You can now continue with the Laravel Quick Start instructions. Or, if you’re a seasoned Laravel pro, continue as you see fit.

Thanks!. If you like this article please share and comment.