Install Laravel 5 on OS X

If you’re like me, you’ve probably spent countless hours on the web trying to figure out how to install the dev-develop version of Laravel on your machine. As of today, the latest Laravel version 4.2 but if you want to see the awesome Laravel 5 features, you need to upgrade.

In this article, you will learn how to setup Laravel 5 from scratch on OS X.

Requirements

Here are some things you must have:

A Terminal

XAMPP / MAMP (I will show you how to set it up using both of them)

Step 1: Installing Composer

Composer is a tool for dependency management in PHP. It allows you to declare the dependent libraries your project needs and it will install them in your project for you.

It allows you to scaffold out a Laravel project and you also have the flexibility of specifying which version of Laravel your want.

Step 2: Configuring XAMPP/MAMP

When installing Laravel for the first time, more than 90% of the people face this dreaded PHP error:

MCrypt PHP extension not installed.

…and then they spend countless hours on the internet trying to figure out how to solve this and most of them will tell you to install MAMP. But what if you have XAMPP installed?

For XAMPP users

I’m using XAMPP 1.8.3–2 on my Mac and it comes with the MCrypt extension out of the box. All you need is to include it’s path in your .bash_profile

Open your .bash_profile by running:

vim ~/.bash_profile

…and paste the following line at the end:

export PATH="/Applications/XAMPP/xamppfiles/bin:$PATH"

Save the file by pressing : and typing wq and then press enter to quit out.

Remember to reload the .bash_profile by running:

source ~/.bash_profile

For MAMP users

The procedure is pretty much the same. You start out by opening your .bash_profile and pasting the following line at the end:

export PATH=/Applications/MAMP/bin/php/php5.6/bin:$PATH

Important note: This assumes that you have PHP 5.6 installed on your machine.

Remember to reload the .bash_profile by running:

source ~/.bash_profile

Step 3: Installing Laravel 5

To create a new Laravel 5 project, run the following:

composer create-project laravel/laravel dev-develop

This will pull in the latest dev branch from the Github repo. If you want the latest stable version, run the following:

composer create-project laravel/laravel --prefer-dist

If everything goes well, try running:

php artisan -V

and if it says:

Laravel Framework version 5.0-dev

then you’re good to go!

To see your new shiny Laravel installation in action visit the public directory in the project to see the awesome new Laravel 5 home page.

Step 4: Installing Laravel Homestead

If you have XAMPP/MAMP installed, you can actually browse to your project’s public directory to see the app in action.

To be honest, I’ve moved on from software like XAMPP and MAMP. They are good if you are just getting started, but for you to get better at deploying apps via the command line and really understand how things work, you need to let it go.

Laravel Homestead is an official, pre-packaged Vagrant “box” that provides you a wonderful development environment without requiring you to install PHP, HHVM, a web server, and any other server software on your local machine.

In other words, Laravel Homestead provides a complete environment for your Laravel project. It’s like having your own Rackspace or Digital Ocean server.

It uses Vagrant which allows you to create lightweight, reproducible, and portable development environments locally.