Blog

07 Oct
2016

Laravel Icon Logo

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.

Posted in: < Laravel >
me@grafxflow avatar

me@grafxflow


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!

Related Posts

12 Thoughts

  1. 15 Apr
    2017

    avatar

    Tom

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

    avatar

    me@grafxflow

    Glad to help
  3. 17 Apr
    2017

    avatar

    Farghana Hussain

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

    avatar

    me@grafxflow

    :)
  5. 02 May
    2017

    avatar

    husnain sultan

    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. 02 May
    2017

    avatar

    me@grafxflow

    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. 29 Jun
    2017

    avatar

    NetLicensing.io

    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. 09 Jul
    2017

    avatar

    Lyndon

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

    avatar

    James Sizemore

    THANK YOU! THANK YOU! THANK YOU!
  10. 03 Jan
    2018

    avatar

    kojiromusashi

    Thank you for this
  11. 22 Jan
    2018

    avatar

    Zahra

    Thank you for your complete guide!
  12. 23 Jan
    2018

    avatar

    Muga

    Yeahy finally!!! This was very much helpful

Add comment

Add comment