Laravel Icon Logo
me@grafxflow

Written by me@grafxflow

07 Oct, 2016

16

25,623

Installing Laravel 5.2 on Mac OS X with MAMP

Okay you would have to be living on a different planet not to be aware of the MVC framework called Laravel, but unlike other MVC's it not a simple case of download and install. It requires the use of the Mac OS X terminal and it is fairly easy. Here is a step by step 'how to' for using with MAMP.

Now before I begin I am guessing that you already having pre-installed MAMP. If not best to get started by downloading and installing it using this link - MAMP.

 Step 1:

Check which version of php is running

Before starting anything make sure you have quit MAMP and it's not running. Mac OS X already has a default Apache and php version installed which are required to install Laravel. So we need to make sure if php needs updating or not, since Laravel 5.2 needs a minimum of php 5.6 upwards. So start by opening the terminal and add the following to make sure Apache is up and running.

sudo /usr/sbin/apachectl start

Then check the version of php.

php -v

The first line of the data output should show the php version. If the output is lower than 5.6 then add the following to the terminal, or jump to Step 2.

curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6

It will then ask for your password and the installing process will start which may take a while to complete. Once done restart apache via the terminal (You can't run both versions of this Apache and MAMP's Apache).

sudo /usr/sbin/apachectl restart

 Step 2:

Download and Install composer

Now Laravel uses composer to manage its dependencies. So at first let's locate the htdocs folder by entering the following in the terminal.

cd /Applications/MAMP/htdocs

Then download and install the composer inside the MAMP htdocs folder by entering the following.

curl -sS http://getcomposer.org/installer | php

NOTE: You may want to create a shortcut for 'composer' to save you having to reinstall it every time - so best to read this other article - Install Composer and make a shortcut on Mac OS X

 Step 3:

Download and Install Laravel

Okay now it's time to install Laravel. Again still in the terminal input the following.

php composer.phar create-project laravel/laravel --prefer-dist

Or if you want to define a folder name use this instead

php composer.phar create-project laravel/laravel folder-name

Or if you want to define a folder name and the version of Laravel - for this example 5.2.

php composer.phar create-project laravel/laravel folder-name "5.2.*" --prefer-dist

Terminal should start listing several components of Laravel as it downloads, such as symphony and sebastian etc.

Laravel terminal install

 Step 4:

Download and Install Laravel Forms and HTML components

One thing to note when installing Laravel 5.2, that by default it doesn't install the 'Forms and HTML components'. So if you want to do this (which I would suggest you do) then you will need to do the following.

Goto the root folder which contains the app folder and resources folder etc. Open the composer.json file and edit the following.

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*"
},

to

"require": {
    "php": ">=5.5.9",
    "laravel/framework": "5.2.*",
    "laravelcollective/html": "5.2.*"
},

Now back in the terminal type the following to get the new Laravel folder installation directory.

cd /Applications/MAMP/htdocs/laravel

Then input this, which will update the version of Laravel with our amended composer.json file.

php /Applications/MAMP/htdocs/composer.phar update

The terminal should show the following output to show its complete.

Loading composer repositories with package information
Updating dependencies (including require-dev)
  - Installing laravelcollective/html (v5.2.4)
    Downloading: 100%         

Writing lock file
Generating autoload files

 Step 5:

Start MAMP and preview Laravel

Before running MAMP you will need to stop the other version of Apache so input the following, which will require a password.

sudo /usr/sbin/apachectl stop

So now its okay to start MAMP. In order to run Laravel 5, MAMP needs to be running a minimum version of php 5.6. If you have installed the latest version of MAMP it should have this by default. But here is how to check which version is running. Open MAMP and choose the Preferences tab.

NOTE: Always check with the hosting/server provider that they are running this version of php or upwards as well. Some may not even allow Laravel to run at all!

mamp app screen 1

Then press the PHP tab and see which checkbox is highlighted. By default is should be set to Version 5.6.25 - this should be okay for Laravel.

mamp app screen 2

Enter the following in the browser window which opens. Either http://localhost:8888/laravel/public/ or http://localhost/laravel/public/.

Laravel star screen

You should now see the default Laravel install page. So as you can see it's fairly easy... Enjoy.

Add comment

16 Response

  1. avatar

    Tom

    15 Apr 2017
    Thanks for sharing this, it helped me a lot!
  2. avatar

    me@grafxflow

    15 Apr 2017
    Glad to help
  3. avatar

    Farghana Hussain

    17 Apr 2017
    Best tutorial for Laravel. thanks a lot!
  4. avatar

    me@grafxflow

    17 Apr 2017
    :)
  5. avatar

    husnain sultan

    02 May 2017
    when i update the version of Laravel with our amended composer.json file at step #4. it says could not find a composer.json file in /

    any ideas?
  6. avatar

    me@grafxflow

    02 May 2017
    Hi Husnain,

    Is the composer file in the /Applications/MAMP/htdocs/laravel directory?

    What are both the directories that contains the 'composer.phar' and the amended 'composer.json' file?
  7. avatar

    NetLicensing.io

    29 Jun 2017
    Nice article, thank you!
    An easy way to try out Laravel in action is to use Laravel 5 Boilerplate / Starter Kit - https://github.com/Labs64/laravel-boilerplate
    This is also offering Docker container, with this you don’t need a local PHP (composer, node.js, etc.) environment.
  8. avatar

    Lyndon

    09 Jul 2017
    i love this tutorial! thanks a lot!
  9. avatar

    James Sizemore

    09 Aug 2017
    THANK YOU! THANK YOU! THANK YOU!
  10. avatar

    kojiromusashi

    03 Jan 2018
    Thank you for this
  11. avatar

    Zahra

    22 Jan 2018
    Thank you for your complete guide!
  12. avatar

    Muga

    23 Jan 2018
    Yeahy finally!!! This was very much helpful
  13. avatar

    James

    10 May 2018
    This is the third tutorial I've tried to follow to install Laravel with MAMP. Every single one ends the same way - everything seems to work successfully, but then when I go to visit the default Laravel page at http://localhost:8888/laravel/public/ I get a 500 error. The other sites on Localhost load fine.

    How do I fix this? Thanks!
  14. avatar

    me@grafxflow

    11 May 2018
    Hi James,

    Just checking are you restarting MAMP after installation.

    Also this is an old tutorial - with the latest version of Laravel you need php 7.1.3 installed.

    Plus do you have the specs of MAMP?

    It might be worth seeing if there are errors listed in laravel.log or /Applications/MAMP/logs/php_error.log or apache_error.log if it exists.

    Get back to me and I will try and help.
  15. avatar

    James

    13 May 2018
    Awesome - it turns out it was a PHP version issue - I upgraded MAMP to the latest version which came with the latest version of PHP, re-followed your instructions, and it worked :-)

    Thanks so much for your help!
  16. avatar

    me@grafxflow

    13 May 2018
    Great always glad to help :)

Smart Search

131 Following
57 Followers

me@grafxflow

Hull, United Kingdom

I am a Full-stack Developer who also started delving into the world of UX/UI Design a few years back. I blog and tweet to hopefully share a little bit of knowledge that can help others around the web. Thanks for stopping by!

Follow